@@ -450,13 +450,13 @@ If that doesn't get a good result, it calls "``lookup_slow()``" which
450
450
takes ``i_rwsem ``, rechecks the cache, and then asks the filesystem
451
451
to find a definitive answer.
452
452
453
- As the last step of `` walk_component() ``, `` step_into() `` will be called either
453
+ As the last step of walk_component(), step_into() will be called either
454
454
directly from walk_component() or from handle_dots(). It calls
455
- `` handle_mounts() `` , to check and handle mount points, in which a new
455
+ handle_mounts(), to check and handle mount points, in which a new
456
456
``struct path `` is created containing a counted reference to the new dentry and
457
457
a reference to the new ``vfsmount `` which is only counted if it is
458
458
different from the previous ``vfsmount ``. Then if there is
459
- a symbolic link, `` step_into() `` calls `` pick_link() `` to deal with it,
459
+ a symbolic link, step_into() calls pick_link() to deal with it,
460
460
otherwise it installs the new ``struct path `` in the ``struct nameidata ``, and
461
461
drops the unneeded references.
462
462
@@ -472,8 +472,8 @@ Handling the final component
472
472
``nd->last_type `` to refer to the final component of the path. It does
473
473
not call ``walk_component() `` that last time. Handling that final
474
474
component remains for the caller to sort out. Those callers are
475
- `` path_lookupat() ``, `` path_parentat() `` and
476
- `` path_openat() `` each of which handles the differing requirements of
475
+ path_lookupat(), path_parentat() and
476
+ path_openat() each of which handles the differing requirements of
477
477
different system calls.
478
478
479
479
``path_parentat() `` is clearly the simplest - it just wraps a little bit
@@ -489,17 +489,17 @@ object is wanted such as by ``stat()`` or ``chmod()``. It essentially just
489
489
calls ``walk_component() `` on the final component through a call to
490
490
``lookup_last() ``. ``path_lookupat() `` returns just the final dentry.
491
491
It is worth noting that when flag ``LOOKUP_MOUNTPOINT `` is set,
492
- `` path_lookupat() `` will unset LOOKUP_JUMPED in nameidata so that in the
493
- subsequent path traversal `` d_weak_revalidate() `` won't be called.
492
+ path_lookupat() will unset LOOKUP_JUMPED in nameidata so that in the
493
+ subsequent path traversal d_weak_revalidate() won't be called.
494
494
This is important when unmounting a filesystem that is inaccessible, such as
495
495
one provided by a dead NFS server.
496
496
497
497
Finally ``path_openat() `` is used for the ``open() `` system call; it
498
- contains, in support functions starting with "`` open_last_lookups() `` ", all the
498
+ contains, in support functions starting with "open_last_lookups()", all the
499
499
complexity needed to handle the different subtleties of O_CREAT (with
500
500
or without O_EXCL), final "``/ ``" characters, and trailing symbolic
501
501
links. We will revisit this in the final part of this series, which
502
- focuses on those symbolic links. "`` open_last_lookups() `` " will sometimes, but
502
+ focuses on those symbolic links. "open_last_lookups()" will sometimes, but
503
503
not always, take ``i_rwsem ``, depending on what it finds.
504
504
505
505
Each of these, or the functions which call them, need to be alert to
@@ -651,9 +651,9 @@ RCU-walk finds it cannot stop gracefully, it simply gives up and
651
651
restarts from the top with REF-walk.
652
652
653
653
This pattern of "try RCU-walk, if that fails try REF-walk" can be
654
- clearly seen in functions like `` filename_lookup() `` ,
655
- `` filename_parentat() `` ,
656
- `` do_filp_open() `` , and `` do_file_open_root() `` . These four
654
+ clearly seen in functions like filename_lookup(),
655
+ filename_parentat(),
656
+ do_filp_open(), and do_file_open_root(). These four
657
657
correspond roughly to the three ``path_*() `` functions we met earlier,
658
658
each of which calls ``link_path_walk() ``. The ``path_*() `` functions are
659
659
called using different mode flags until a mode is found which works.
@@ -1069,8 +1069,8 @@ all the data structures it references are safe to be accessed while
1069
1069
holding no counted reference, only the RCU lock. A callback
1070
1070
``struct delayed_called `` will be passed to ``->get_link() ``:
1071
1071
file systems can set their own put_link function and argument through
1072
- `` set_delayed_call() `` . Later on, when VFS wants to put link, it will call
1073
- `` do_delayed_call() `` to invoke that callback function with the argument.
1072
+ set_delayed_call(). Later on, when VFS wants to put link, it will call
1073
+ do_delayed_call() to invoke that callback function with the argument.
1074
1074
1075
1075
In order for the reference to each symlink to be dropped when the walk completes,
1076
1076
whether in RCU-walk or REF-walk, the symlink stack needs to contain,
@@ -1103,7 +1103,7 @@ doesn't need to notice. Getting this ``name`` variable on and off the
1103
1103
stack is very straightforward; pushing and popping the references is
1104
1104
a little more complex.
1105
1105
1106
- When a symlink is found, `` walk_component() `` calls `` pick_link() `` via `` step_into() ``
1106
+ When a symlink is found, walk_component() calls pick_link() via step_into()
1107
1107
which returns the link from the filesystem.
1108
1108
Providing that operation is successful, the old path ``name `` is placed on the
1109
1109
stack, and the new value is used as the ``name `` for a while. When the end of
@@ -1136,10 +1136,10 @@ Symlinks with no final component
1136
1136
1137
1137
A pair of special-case symlinks deserve a little further explanation.
1138
1138
Both result in a new ``struct path `` (with mount and dentry) being set
1139
- up in the ``nameidata ``, and result in `` pick_link() `` returning ``NULL ``.
1139
+ up in the ``nameidata ``, and result in pick_link() returning ``NULL ``.
1140
1140
1141
1141
The more obvious case is a symlink to "``/ ``". All symlinks starting
1142
- with "``/ ``" are detected in `` pick_link() `` which resets the ``nameidata ``
1142
+ with "``/ ``" are detected in pick_link() which resets the ``nameidata ``
1143
1143
to point to the effective filesystem root. If the symlink only
1144
1144
contains "``/ ``" then there is nothing more to do, no components at all,
1145
1145
so ``NULL `` is returned to indicate that the symlink can be released and
@@ -1157,9 +1157,9 @@ target file, not just the name of it. When you ``readlink`` these
1157
1157
objects you get a name that might refer to the same file - unless it
1158
1158
has been unlinked or mounted over. When ``walk_component() `` follows
1159
1159
one of these, the ``->get_link() `` method in "procfs" doesn't return
1160
- a string name, but instead calls `` nd_jump_link() `` which updates the
1160
+ a string name, but instead calls nd_jump_link() which updates the
1161
1161
``nameidata `` in place to point to that target. ``->get_link() `` then
1162
- returns ``NULL ``. Again there is no final component and `` pick_link() ``
1162
+ returns ``NULL ``. Again there is no final component and pick_link()
1163
1163
returns ``NULL ``.
1164
1164
1165
1165
Following the symlink in the final component
@@ -1177,35 +1177,35 @@ potentially need to call ``link_path_walk()`` again and again on
1177
1177
successive symlinks until one is found that doesn't point to another
1178
1178
symlink.
1179
1179
1180
- This case is handled by relevant callers of `` link_path_walk() `` , such as
1181
- `` path_lookupat() ``, `` path_openat() `` using a loop that calls `` link_path_walk() `` ,
1182
- and then handles the final component by calling `` open_last_lookups() `` or
1183
- `` lookup_last() `` . If it is a symlink that needs to be followed,
1184
- `` open_last_lookups() `` or `` lookup_last() `` will set things up properly and
1180
+ This case is handled by relevant callers of link_path_walk(), such as
1181
+ path_lookupat(), path_openat() using a loop that calls link_path_walk(),
1182
+ and then handles the final component by calling open_last_lookups() or
1183
+ lookup_last(). If it is a symlink that needs to be followed,
1184
+ open_last_lookups() or lookup_last() will set things up properly and
1185
1185
return the path so that the loop repeats, calling
1186
- `` link_path_walk() `` again. This could loop as many as 40 times if the last
1186
+ link_path_walk() again. This could loop as many as 40 times if the last
1187
1187
component of each symlink is another symlink.
1188
1188
1189
1189
Of the various functions that examine the final component,
1190
- `` open_last_lookups() `` is the most interesting as it works in tandem
1191
- with `` do_open() `` for opening a file. Part of `` open_last_lookups() `` runs
1192
- with ``i_rwsem `` held and this part is in a separate function: `` lookup_open() `` .
1190
+ open_last_lookups() is the most interesting as it works in tandem
1191
+ with do_open() for opening a file. Part of open_last_lookups() runs
1192
+ with ``i_rwsem `` held and this part is in a separate function: lookup_open().
1193
1193
1194
- Explaining `` open_last_lookups() `` and `` do_open() `` completely is beyond the scope
1194
+ Explaining open_last_lookups() and do_open() completely is beyond the scope
1195
1195
of this article, but a few highlights should help those interested in exploring
1196
1196
the code.
1197
1197
1198
- 1. Rather than just finding the target file, `` do_open() `` is used after
1199
- `` open_last_lookup() `` to open
1198
+ 1. Rather than just finding the target file, do_open() is used after
1199
+ open_last_lookup() to open
1200
1200
it. If the file was found in the dcache, then ``vfs_open() `` is used for
1201
1201
this. If not, then ``lookup_open() `` will either call ``atomic_open() `` (if
1202
1202
the filesystem provides it) to combine the final lookup with the open, or
1203
1203
will perform the separate ``i_op->lookup() `` and ``i_op->create() `` steps
1204
1204
directly. In the later case the actual "open" of this newly found or
1205
- created file will be performed by `` vfs_open() `` , just as if the name
1205
+ created file will be performed by vfs_open(), just as if the name
1206
1206
were found in the dcache.
1207
1207
1208
- 2. `` vfs_open() `` can fail with ``-EOPENSTALE `` if the cached information
1208
+ 2. vfs_open() can fail with ``-EOPENSTALE `` if the cached information
1209
1209
wasn't quite current enough. If it's in RCU-walk ``-ECHILD `` will be returned
1210
1210
otherwise ``-ESTALE `` is returned. When ``-ESTALE `` is returned, the caller may
1211
1211
retry with ``LOOKUP_REVAL `` flag set.
@@ -1218,8 +1218,8 @@ the code.
1218
1218
1219
1219
will create a file called ``/tmp/bar ``. This is not permitted if
1220
1220
``O_EXCL `` is set but otherwise is handled for an O_CREAT open much
1221
- like for a non-creating open: `` lookup_last() `` or `` open_last_lookup() ``
1222
- returns a non ``NULL `` value, and `` link_path_walk() `` gets called and the
1221
+ like for a non-creating open: lookup_last() or open_last_lookup()
1222
+ returns a non ``NULL `` value, and link_path_walk() gets called and the
1223
1223
open process continues on the symlink that was found.
1224
1224
1225
1225
Updating the access time
0 commit comments