Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: filesystems: convert sharedsubtree.txt to ReST

- Add a SPDX header;
- Adjust document and section titles;
- Some whitespace fixes and new line breaks;
- Mark literal blocks as such;
- Add table markups;
- Add it to filesystems/index.rst

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/6692b8abc177130e9e53aace94117a2ad076cab5.1588021877.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
cf06612c 53a41d3e

+228 -171
+1
Documentation/filesystems/index.rst
··· 33 33 mount_api 34 34 quota 35 35 seq_file 36 + sharedsubtree 36 37 37 38 automount-support 38 39
+1 -1
Documentation/filesystems/proc.rst
··· 1870 1870 1871 1871 For more information on mount propagation see: 1872 1872 1873 - Documentation/filesystems/sharedsubtree.txt 1873 + Documentation/filesystems/sharedsubtree.rst 1874 1874 1875 1875 1876 1876 3.6 /proc/<pid>/comm & /proc/<pid>/task/<tid>/comm
+226 -170
Documentation/filesystems/sharedsubtree.txt Documentation/filesystems/sharedsubtree.rst
··· 1 - Shared Subtrees 2 - --------------- 1 + .. SPDX-License-Identifier: GPL-2.0 3 2 4 - Contents: 3 + =============== 4 + Shared Subtrees 5 + =============== 6 + 7 + .. Contents: 5 8 1) Overview 6 9 2) Features 7 10 3) Setting mount states ··· 44 41 45 42 Here is an example: 46 43 47 - Let's say /mnt has a mount that is shared. 48 - mount --make-shared /mnt 44 + Let's say /mnt has a mount that is shared:: 45 + 46 + mount --make-shared /mnt 49 47 50 48 Note: mount(8) command now supports the --make-shared flag, 51 49 so the sample 'smount' program is no longer needed and has been 52 50 removed. 53 51 54 - # mount --bind /mnt /tmp 52 + :: 53 + 54 + # mount --bind /mnt /tmp 55 + 55 56 The above command replicates the mount at /mnt to the mountpoint /tmp 56 57 and the contents of both the mounts remain identical. 57 58 58 - #ls /mnt 59 - a b c 59 + :: 60 60 61 - #ls /tmp 62 - a b c 61 + #ls /mnt 62 + a b c 63 63 64 - Now let's say we mount a device at /tmp/a 65 - # mount /dev/sd0 /tmp/a 64 + #ls /tmp 65 + a b c 66 66 67 - #ls /tmp/a 68 - t1 t2 t3 67 + Now let's say we mount a device at /tmp/a:: 69 68 70 - #ls /mnt/a 71 - t1 t2 t3 69 + # mount /dev/sd0 /tmp/a 70 + 71 + #ls /tmp/a 72 + t1 t2 t3 73 + 74 + #ls /mnt/a 75 + t1 t2 t3 72 76 73 77 Note that the mount has propagated to the mount at /mnt as well. 74 78 ··· 133 123 134 124 2d) A unbindable mount is a unbindable private mount 135 125 136 - let's say we have a mount at /mnt and we make it unbindable 126 + let's say we have a mount at /mnt and we make it unbindable:: 137 127 138 - # mount --make-unbindable /mnt 128 + # mount --make-unbindable /mnt 139 129 140 - Let's try to bind mount this mount somewhere else. 141 - # mount --bind /mnt /tmp 142 - mount: wrong fs type, bad option, bad superblock on /mnt, 143 - or too many mounted file systems 130 + Let's try to bind mount this mount somewhere else:: 131 + 132 + # mount --bind /mnt /tmp 133 + mount: wrong fs type, bad option, bad superblock on /mnt, 134 + or too many mounted file systems 144 135 145 136 Binding a unbindable mount is a invalid operation. 146 137 ··· 149 138 3) Setting mount states 150 139 151 140 The mount command (util-linux package) can be used to set mount 152 - states: 141 + states:: 153 142 154 - mount --make-shared mountpoint 155 - mount --make-slave mountpoint 156 - mount --make-private mountpoint 157 - mount --make-unbindable mountpoint 143 + mount --make-shared mountpoint 144 + mount --make-slave mountpoint 145 + mount --make-private mountpoint 146 + mount --make-unbindable mountpoint 158 147 159 148 160 149 4) Use cases ··· 165 154 166 155 Solution: 167 156 168 - The system administrator can make the mount at /cdrom shared 169 - mount --bind /cdrom /cdrom 170 - mount --make-shared /cdrom 157 + The system administrator can make the mount at /cdrom shared:: 158 + 159 + mount --bind /cdrom /cdrom 160 + mount --make-shared /cdrom 171 161 172 162 Now any process that clones off a new namespace will have a 173 163 mount at /cdrom which is a replica of the same mount in the ··· 184 172 Solution: 185 173 186 174 To begin with, the administrator can mark the entire mount tree 187 - as shareable. 175 + as shareable:: 188 176 189 - mount --make-rshared / 177 + mount --make-rshared / 190 178 191 179 A new process can clone off a new namespace. And mark some part 192 - of its namespace as slave 180 + of its namespace as slave:: 193 181 194 - mount --make-rslave /myprivatetree 182 + mount --make-rslave /myprivatetree 195 183 196 184 Hence forth any mounts within the /myprivatetree done by the 197 185 process will not show up in any other namespace. However mounts ··· 218 206 versions of the file depending on the path used to access that 219 207 file. 220 208 221 - An example is: 209 + An example is:: 222 210 223 - mount --make-shared / 224 - mount --rbind / /view/v1 225 - mount --rbind / /view/v2 226 - mount --rbind / /view/v3 227 - mount --rbind / /view/v4 211 + mount --make-shared / 212 + mount --rbind / /view/v1 213 + mount --rbind / /view/v2 214 + mount --rbind / /view/v3 215 + mount --rbind / /view/v4 228 216 229 217 and if /usr has a versioning filesystem mounted, then that 230 218 mount appears at /view/v1/usr, /view/v2/usr, /view/v3/usr and ··· 236 224 filesystem is being requested and return the corresponding 237 225 inode. 238 226 239 - 5) Detailed semantics: 240 - ------------------- 227 + 5) Detailed semantics 228 + --------------------- 241 229 The section below explains the detailed semantics of 242 230 bind, rbind, move, mount, umount and clone-namespace operations. 243 231 ··· 247 235 5a) Mount states 248 236 249 237 A given mount can be in one of the following states 238 + 250 239 1) shared 251 240 2) slave 252 241 3) shared and slave ··· 265 252 A 'shared mount' is defined as a vfsmount that belongs to a 266 253 'peer group'. 267 254 268 - For example: 255 + For example:: 256 + 269 257 mount --make-shared /mnt 270 258 mount --bind /mnt /tmp 271 259 ··· 284 270 A slave mount as the name implies has a master mount from which 285 271 mount/unmount events are received. Events do not propagate from 286 272 the slave mount to the master. Only a shared mount can be made 287 - a slave by executing the following command 273 + a slave by executing the following command:: 288 274 289 275 mount --make-slave mount 290 276 ··· 304 290 peer group. 305 291 306 292 Only a slave vfsmount can be made as 'shared and slave' by 307 - either executing the following command 293 + either executing the following command:: 294 + 308 295 mount --make-shared mount 296 + 309 297 or by moving the slave vfsmount under a shared vfsmount. 310 298 311 299 (4) Private mount ··· 323 307 324 308 325 309 State diagram: 310 + 326 311 The state diagram below explains the state transition of a mount, 327 - in response to various commands. 328 - ------------------------------------------------------------------------ 329 - | |make-shared | make-slave | make-private |make-unbindab| 330 - --------------|------------|--------------|--------------|-------------| 331 - |shared |shared |*slave/private| private | unbindable | 332 - | | | | | | 333 - |-------------|------------|--------------|--------------|-------------| 334 - |slave |shared | **slave | private | unbindable | 335 - | |and slave | | | | 336 - |-------------|------------|--------------|--------------|-------------| 337 - |shared |shared | slave | private | unbindable | 338 - |and slave |and slave | | | | 339 - |-------------|------------|--------------|--------------|-------------| 340 - |private |shared | **private | private | unbindable | 341 - |-------------|------------|--------------|--------------|-------------| 342 - |unbindable |shared |**unbindable | private | unbindable | 343 - ------------------------------------------------------------------------ 312 + in response to various commands:: 344 313 345 - * if the shared mount is the only mount in its peer group, making it 346 - slave, makes it private automatically. Note that there is no master to 347 - which it can be slaved to. 314 + ----------------------------------------------------------------------- 315 + | |make-shared | make-slave | make-private |make-unbindab| 316 + --------------|------------|--------------|--------------|-------------| 317 + |shared |shared |*slave/private| private | unbindable | 318 + | | | | | | 319 + |-------------|------------|--------------|--------------|-------------| 320 + |slave |shared | **slave | private | unbindable | 321 + | |and slave | | | | 322 + |-------------|------------|--------------|--------------|-------------| 323 + |shared |shared | slave | private | unbindable | 324 + |and slave |and slave | | | | 325 + |-------------|------------|--------------|--------------|-------------| 326 + |private |shared | **private | private | unbindable | 327 + |-------------|------------|--------------|--------------|-------------| 328 + |unbindable |shared |**unbindable | private | unbindable | 329 + ------------------------------------------------------------------------ 348 330 349 - ** slaving a non-shared mount has no effect on the mount. 331 + * if the shared mount is the only mount in its peer group, making it 332 + slave, makes it private automatically. Note that there is no master to 333 + which it can be slaved to. 334 + 335 + ** slaving a non-shared mount has no effect on the mount. 350 336 351 337 Apart from the commands listed below, the 'move' operation also changes 352 338 the state of a mount depending on type of the destination mount. Its ··· 356 338 357 339 5b) Bind semantics 358 340 359 - Consider the following command 341 + Consider the following command:: 360 342 361 - mount --bind A/a B/b 343 + mount --bind A/a B/b 362 344 363 345 where 'A' is the source mount, 'a' is the dentry in the mount 'A', 'B' 364 346 is the destination mount and 'b' is the dentry in the destination mount. 365 347 366 348 The outcome depends on the type of mount of 'A' and 'B'. The table 367 - below contains quick reference. 368 - --------------------------------------------------------------------------- 369 - | BIND MOUNT OPERATION | 370 - |************************************************************************** 371 - |source(A)->| shared | private | slave | unbindable | 372 - | dest(B) | | | | | 373 - | | | | | | | 374 - | v | | | | | 375 - |************************************************************************** 376 - | shared | shared | shared | shared & slave | invalid | 377 - | | | | | | 378 - |non-shared| shared | private | slave | invalid | 379 - *************************************************************************** 349 + below contains quick reference:: 350 + 351 + -------------------------------------------------------------------------- 352 + | BIND MOUNT OPERATION | 353 + |************************************************************************| 354 + |source(A)->| shared | private | slave | unbindable | 355 + | dest(B) | | | | | 356 + | | | | | | | 357 + | v | | | | | 358 + |************************************************************************| 359 + | shared | shared | shared | shared & slave | invalid | 360 + | | | | | | 361 + |non-shared| shared | private | slave | invalid | 362 + ************************************************************************** 380 363 381 364 Details: 382 365 383 - 1. 'A' is a shared mount and 'B' is a shared mount. A new mount 'C' 366 + 1. 'A' is a shared mount and 'B' is a shared mount. A new mount 'C' 384 367 which is clone of 'A', is created. Its root dentry is 'a' . 'C' is 385 368 mounted on mount 'B' at dentry 'b'. Also new mount 'C1', 'C2', 'C3' ... 386 369 are created and mounted at the dentry 'b' on all mounts where 'B' ··· 390 371 'B'. And finally the peer-group of 'C' is merged with the peer group 391 372 of 'A'. 392 373 393 - 2. 'A' is a private mount and 'B' is a shared mount. A new mount 'C' 374 + 2. 'A' is a private mount and 'B' is a shared mount. A new mount 'C' 394 375 which is clone of 'A', is created. Its root dentry is 'a'. 'C' is 395 376 mounted on mount 'B' at dentry 'b'. Also new mount 'C1', 'C2', 'C3' ... 396 377 are created and mounted at the dentry 'b' on all mounts where 'B' ··· 398 379 'C', 'C1', .., 'Cn' with exactly the same configuration as the 399 380 propagation tree for 'B'. 400 381 401 - 3. 'A' is a slave mount of mount 'Z' and 'B' is a shared mount. A new 382 + 3. 'A' is a slave mount of mount 'Z' and 'B' is a shared mount. A new 402 383 mount 'C' which is clone of 'A', is created. Its root dentry is 'a' . 403 384 'C' is mounted on mount 'B' at dentry 'b'. Also new mounts 'C1', 'C2', 404 385 'C3' ... are created and mounted at the dentry 'b' on all mounts where ··· 408 389 is made the slave of mount 'Z'. In other words, mount 'C' is in the 409 390 state 'slave and shared'. 410 391 411 - 4. 'A' is a unbindable mount and 'B' is a shared mount. This is a 392 + 4. 'A' is a unbindable mount and 'B' is a shared mount. This is a 412 393 invalid operation. 413 394 414 - 5. 'A' is a private mount and 'B' is a non-shared(private or slave or 395 + 5. 'A' is a private mount and 'B' is a non-shared(private or slave or 415 396 unbindable) mount. A new mount 'C' which is clone of 'A', is created. 416 397 Its root dentry is 'a'. 'C' is mounted on mount 'B' at dentry 'b'. 417 398 418 - 6. 'A' is a shared mount and 'B' is a non-shared mount. A new mount 'C' 399 + 6. 'A' is a shared mount and 'B' is a non-shared mount. A new mount 'C' 419 400 which is a clone of 'A' is created. Its root dentry is 'a'. 'C' is 420 401 mounted on mount 'B' at dentry 'b'. 'C' is made a member of the 421 402 peer-group of 'A'. 422 403 423 - 7. 'A' is a slave mount of mount 'Z' and 'B' is a non-shared mount. A 404 + 7. 'A' is a slave mount of mount 'Z' and 'B' is a non-shared mount. A 424 405 new mount 'C' which is a clone of 'A' is created. Its root dentry is 425 406 'a'. 'C' is mounted on mount 'B' at dentry 'b'. Also 'C' is set as a 426 407 slave mount of 'Z'. In other words 'A' and 'C' are both slave mounts of ··· 428 409 mount/unmount on 'A' do not propagate anywhere else. Similarly 429 410 mount/unmount on 'C' do not propagate anywhere else. 430 411 431 - 8. 'A' is a unbindable mount and 'B' is a non-shared mount. This is a 412 + 8. 'A' is a unbindable mount and 'B' is a non-shared mount. This is a 432 413 invalid operation. A unbindable mount cannot be bind mounted. 433 414 434 415 5c) Rbind semantics ··· 441 422 then the subtree under the unbindable mount is pruned in the new 442 423 location. 443 424 444 - eg: let's say we have the following mount tree. 425 + eg: 426 + 427 + let's say we have the following mount tree:: 445 428 446 429 A 447 430 / \ ··· 451 430 / \ / \ 452 431 D E F G 453 432 454 - Let's say all the mount except the mount C in the tree are 455 - of a type other than unbindable. 433 + Let's say all the mount except the mount C in the tree are 434 + of a type other than unbindable. 456 435 457 - If this tree is rbound to say Z 436 + If this tree is rbound to say Z 458 437 459 - We will have the following tree at the new location. 438 + We will have the following tree at the new location:: 460 439 461 440 Z 462 441 | ··· 478 457 the dentry in the destination mount. 479 458 480 459 The outcome depends on the type of the mount of 'A' and 'B'. The table 481 - below is a quick reference. 482 - --------------------------------------------------------------------------- 483 - | MOVE MOUNT OPERATION | 484 - |************************************************************************** 485 - | source(A)->| shared | private | slave | unbindable | 486 - | dest(B) | | | | | 487 - | | | | | | | 488 - | v | | | | | 489 - |************************************************************************** 490 - | shared | shared | shared |shared and slave| invalid | 491 - | | | | | | 492 - |non-shared| shared | private | slave | unbindable | 493 - *************************************************************************** 494 - NOTE: moving a mount residing under a shared mount is invalid. 460 + below is a quick reference:: 461 + 462 + --------------------------------------------------------------------------- 463 + | MOVE MOUNT OPERATION | 464 + |************************************************************************** 465 + | source(A)->| shared | private | slave | unbindable | 466 + | dest(B) | | | | | 467 + | | | | | | | 468 + | v | | | | | 469 + |************************************************************************** 470 + | shared | shared | shared |shared and slave| invalid | 471 + | | | | | | 472 + |non-shared| shared | private | slave | unbindable | 473 + *************************************************************************** 474 + 475 + .. Note:: moving a mount residing under a shared mount is invalid. 495 476 496 477 Details follow: 497 478 498 - 1. 'A' is a shared mount and 'B' is a shared mount. The mount 'A' is 479 + 1. 'A' is a shared mount and 'B' is a shared mount. The mount 'A' is 499 480 mounted on mount 'B' at dentry 'b'. Also new mounts 'A1', 'A2'...'An' 500 481 are created and mounted at dentry 'b' on all mounts that receive 501 482 propagation from mount 'B'. A new propagation tree is created in the ··· 506 483 propagation tree is appended to the already existing propagation tree 507 484 of 'A'. 508 485 509 - 2. 'A' is a private mount and 'B' is a shared mount. The mount 'A' is 486 + 2. 'A' is a private mount and 'B' is a shared mount. The mount 'A' is 510 487 mounted on mount 'B' at dentry 'b'. Also new mount 'A1', 'A2'... 'An' 511 488 are created and mounted at dentry 'b' on all mounts that receive 512 489 propagation from mount 'B'. The mount 'A' becomes a shared mount and a ··· 514 491 'B'. This new propagation tree contains all the new mounts 'A1', 515 492 'A2'... 'An'. 516 493 517 - 3. 'A' is a slave mount of mount 'Z' and 'B' is a shared mount. The 494 + 3. 'A' is a slave mount of mount 'Z' and 'B' is a shared mount. The 518 495 mount 'A' is mounted on mount 'B' at dentry 'b'. Also new mounts 'A1', 519 496 'A2'... 'An' are created and mounted at dentry 'b' on all mounts that 520 497 receive propagation from mount 'B'. A new propagation tree is created ··· 524 501 'A'. Mount 'A' continues to be the slave mount of 'Z' but it also 525 502 becomes 'shared'. 526 503 527 - 4. 'A' is a unbindable mount and 'B' is a shared mount. The operation 504 + 4. 'A' is a unbindable mount and 'B' is a shared mount. The operation 528 505 is invalid. Because mounting anything on the shared mount 'B' can 529 506 create new mounts that get mounted on the mounts that receive 530 507 propagation from 'B'. And since the mount 'A' is unbindable, cloning 531 508 it to mount at other mountpoints is not possible. 532 509 533 - 5. 'A' is a private mount and 'B' is a non-shared(private or slave or 510 + 5. 'A' is a private mount and 'B' is a non-shared(private or slave or 534 511 unbindable) mount. The mount 'A' is mounted on mount 'B' at dentry 'b'. 535 512 536 - 6. 'A' is a shared mount and 'B' is a non-shared mount. The mount 'A' 513 + 6. 'A' is a shared mount and 'B' is a non-shared mount. The mount 'A' 537 514 is mounted on mount 'B' at dentry 'b'. Mount 'A' continues to be a 538 515 shared mount. 539 516 540 - 7. 'A' is a slave mount of mount 'Z' and 'B' is a non-shared mount. 517 + 7. 'A' is a slave mount of mount 'Z' and 'B' is a non-shared mount. 541 518 The mount 'A' is mounted on mount 'B' at dentry 'b'. Mount 'A' 542 519 continues to be a slave mount of mount 'Z'. 543 520 544 - 8. 'A' is a unbindable mount and 'B' is a non-shared mount. The mount 521 + 8. 'A' is a unbindable mount and 'B' is a non-shared mount. The mount 545 522 'A' is mounted on mount 'B' at dentry 'b'. Mount 'A' continues to be a 546 523 unbindable mount. 547 524 548 525 5e) Mount semantics 549 526 550 - Consider the following command 527 + Consider the following command:: 551 528 552 - mount device B/b 529 + mount device B/b 553 530 554 531 'B' is the destination mount and 'b' is the dentry in the destination 555 532 mount. ··· 560 537 561 538 5f) Unmount semantics 562 539 563 - Consider the following command 540 + Consider the following command:: 564 541 565 - umount A 542 + umount A 566 543 567 544 where 'A' is a mount mounted on mount 'B' at dentry 'b'. 568 545 ··· 615 592 616 593 A. What is the result of the following command sequence? 617 594 618 - mount --bind /mnt /mnt 619 - mount --make-shared /mnt 620 - mount --bind /mnt /tmp 621 - mount --move /tmp /mnt/1 595 + :: 596 + 597 + mount --bind /mnt /mnt 598 + mount --make-shared /mnt 599 + mount --bind /mnt /tmp 600 + mount --move /tmp /mnt/1 622 601 623 602 what should be the contents of /mnt /mnt/1 /mnt/1/1 should be? 624 603 Should they all be identical? or should /mnt and /mnt/1 be ··· 629 604 630 605 B. What is the result of the following command sequence? 631 606 632 - mount --make-rshared / 633 - mkdir -p /v/1 634 - mount --rbind / /v/1 607 + :: 608 + 609 + mount --make-rshared / 610 + mkdir -p /v/1 611 + mount --rbind / /v/1 635 612 636 613 what should be the content of /v/1/v/1 be? 637 614 638 615 639 616 C. What is the result of the following command sequence? 640 617 641 - mount --bind /mnt /mnt 642 - mount --make-shared /mnt 643 - mkdir -p /mnt/1/2/3 /mnt/1/test 644 - mount --bind /mnt/1 /tmp 645 - mount --make-slave /mnt 646 - mount --make-shared /mnt 647 - mount --bind /mnt/1/2 /tmp1 648 - mount --make-slave /mnt 618 + :: 619 + 620 + mount --bind /mnt /mnt 621 + mount --make-shared /mnt 622 + mkdir -p /mnt/1/2/3 /mnt/1/test 623 + mount --bind /mnt/1 /tmp 624 + mount --make-slave /mnt 625 + mount --make-shared /mnt 626 + mount --bind /mnt/1/2 /tmp1 627 + mount --make-slave /mnt 649 628 650 629 At this point we have the first mount at /tmp and 651 630 its root dentry is 1. Let's call this mount 'A' ··· 697 668 698 669 step 1: 699 670 let's say the root tree has just two directories with 700 - one vfsmount. 671 + one vfsmount:: 672 + 701 673 root 702 674 / \ 703 675 tmp usr ··· 706 676 And we want to replicate the tree at multiple 707 677 mountpoints under /root/tmp 708 678 709 - step2: 710 - mount --make-shared /root 679 + step 2: 680 + :: 711 681 712 - mkdir -p /tmp/m1 713 682 714 - mount --rbind /root /tmp/m1 683 + mount --make-shared /root 715 684 716 - the new tree now looks like this: 685 + mkdir -p /tmp/m1 686 + 687 + mount --rbind /root /tmp/m1 688 + 689 + the new tree now looks like this:: 717 690 718 691 root 719 692 / \ ··· 730 697 731 698 it has two vfsmounts 732 699 733 - step3: 700 + step 3: 701 + :: 702 + 734 703 mkdir -p /tmp/m2 735 704 mount --rbind /root /tmp/m2 736 705 737 - the new tree now looks like this: 706 + the new tree now looks like this:: 738 707 739 708 root 740 709 / \ ··· 759 724 it has 6 vfsmounts 760 725 761 726 step 4: 727 + :: 762 728 mkdir -p /tmp/m3 763 729 mount --rbind /root /tmp/m3 764 730 ··· 776 740 777 741 step 1: 778 742 let's say the root tree has just two directories with 779 - one vfsmount. 743 + one vfsmount:: 744 + 780 745 root 781 746 / \ 782 747 tmp usr ··· 785 748 How do we set up the same tree at multiple locations under 786 749 /root/tmp 787 750 788 - step2: 789 - mount --bind /root/tmp /root/tmp 751 + step 2: 752 + :: 790 753 791 - mount --make-rshared /root 792 - mount --make-unbindable /root/tmp 793 754 794 - mkdir -p /tmp/m1 755 + mount --bind /root/tmp /root/tmp 795 756 796 - mount --rbind /root /tmp/m1 757 + mount --make-rshared /root 758 + mount --make-unbindable /root/tmp 797 759 798 - the new tree now looks like this: 760 + mkdir -p /tmp/m1 761 + 762 + mount --rbind /root /tmp/m1 763 + 764 + the new tree now looks like this:: 799 765 800 766 root 801 767 / \ ··· 808 768 / \ 809 769 tmp usr 810 770 811 - step3: 771 + step 3: 772 + :: 773 + 812 774 mkdir -p /tmp/m2 813 775 mount --rbind /root /tmp/m2 814 776 815 - the new tree now looks like this: 777 + the new tree now looks like this:: 816 778 817 779 root 818 780 / \ ··· 824 782 / \ / \ 825 783 tmp usr tmp usr 826 784 827 - step4: 785 + step 4: 786 + :: 828 787 829 788 mkdir -p /tmp/m3 830 789 mount --rbind /root /tmp/m3 831 790 832 - the new tree now looks like this: 791 + the new tree now looks like this:: 833 792 834 793 root 835 794 / \ ··· 844 801 845 802 8A) Datastructure 846 803 847 - 4 new fields are introduced to struct vfsmount 848 - ->mnt_share 849 - ->mnt_slave_list 850 - ->mnt_slave 851 - ->mnt_master 804 + 4 new fields are introduced to struct vfsmount: 852 805 853 - ->mnt_share links together all the mount to/from which this vfsmount 806 + * ->mnt_share 807 + * ->mnt_slave_list 808 + * ->mnt_slave 809 + * ->mnt_master 810 + 811 + ->mnt_share 812 + links together all the mount to/from which this vfsmount 854 813 send/receives propagation events. 855 814 856 - ->mnt_slave_list links all the mounts to which this vfsmount propagates 815 + ->mnt_slave_list 816 + links all the mounts to which this vfsmount propagates 857 817 to. 858 818 859 - ->mnt_slave links together all the slaves that its master vfsmount 819 + ->mnt_slave 820 + links together all the slaves that its master vfsmount 860 821 propagates to. 861 822 862 - ->mnt_master points to the master vfsmount from which this vfsmount 823 + ->mnt_master 824 + points to the master vfsmount from which this vfsmount 863 825 receives propagation. 864 826 865 - ->mnt_flags takes two more flags to indicate the propagation status of 827 + ->mnt_flags 828 + takes two more flags to indicate the propagation status of 866 829 the vfsmount. MNT_SHARE indicates that the vfsmount is a shared 867 830 vfsmount. MNT_UNCLONABLE indicates that the vfsmount cannot be 868 831 replicated. ··· 891 842 892 843 A example propagation tree looks as shown in the figure below. 893 844 [ NOTE: Though it looks like a forest, if we consider all the shared 894 - mounts as a conceptual entity called 'pnode', it becomes a tree] 845 + mounts as a conceptual entity called 'pnode', it becomes a tree]:: 895 846 896 847 897 848 A <--> B <--> C <---> D ··· 913 864 A's ->mnt_slave_list links with ->mnt_slave of 'E', 'K', 'F' and 'G' 914 865 915 866 E's ->mnt_share links with ->mnt_share of K 916 - 'E', 'K', 'F', 'G' have their ->mnt_master point to struct 917 - vfsmount of 'A' 867 + 868 + 'E', 'K', 'F', 'G' have their ->mnt_master point to struct vfsmount of 'A' 869 + 918 870 'M', 'L', 'N' have their ->mnt_master point to struct vfsmount of 'K' 871 + 919 872 K's ->mnt_slave_list links with ->mnt_slave of 'M', 'L' and 'N' 920 873 921 874 C's ->mnt_slave_list links with ->mnt_slave of 'J' and 'K' 875 + 922 876 J and K's ->mnt_master points to struct vfsmount of C 877 + 923 878 and finally D's ->mnt_slave_list links with ->mnt_slave of 'H' and 'I' 879 + 924 880 'H' and 'I' have their ->mnt_master pointing to struct vfsmount of 'D'. 925 881 926 882 ··· 957 903 Prepare phase: 958 904 959 905 for each mount in the source tree: 906 + 960 907 a) Create the necessary number of mount trees to 961 908 be attached to each of the mounts that receive 962 909 propagation from the destination mount. ··· 984 929 Abort phase 985 930 delete all the newly created trees. 986 931 987 - NOTE: all the propagation related functionality resides in the file 988 - pnode.c 932 + .. Note:: 933 + all the propagation related functionality resides in the file pnode.c 989 934 990 935 991 936 ------------------------------------------------------------------------ 992 937 993 938 version 0.1 (created the initial document, Ram Pai linuxram@us.ibm.com) 939 + 994 940 version 0.2 (Incorporated comments from Al Viro)