Skip to content

Commit 71e0a67

Browse files
foxhlchenJonathan Corbet
authored andcommitted
docs: path-lookup: update do_last() part
traling_symlink() was merged into lookup_last, do_last(). do_last() has later been split into open_last_lookups() and do_open(). see related commit: commit c5971b8 ("take post-lookup part of do_last() out of loop") Signed-off-by: Fox Chen <foxhlchen@gmail.com> Reviewed-by: NeilBrown <neilb@suse.de> Link: https://lore.kernel.org/r/20210527091618.287093-5-foxhlchen@gmail.com Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent 8593d2c commit 71e0a67

1 file changed

Lines changed: 22 additions & 25 deletions

File tree

Documentation/filesystems/path-lookup.rst

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,11 @@ This is important when unmounting a filesystem that is inaccessible, such as
495495
one provided by a dead NFS server.
496496

497497
Finally ``path_openat()`` is used for the ``open()`` system call; it
498-
contains, in support functions starting with "``do_last()``", all the
498+
contains, in support functions starting with "``open_last_lookups()``", all the
499499
complexity needed to handle the different subtleties of O_CREAT (with
500500
or without O_EXCL), final "``/``" characters, and trailing symbolic
501501
links. We will revisit this in the final part of this series, which
502-
focuses on those symbolic links. "``do_last()``" will sometimes, but
502+
focuses on those symbolic links. "``open_last_lookups()``" will sometimes, but
503503
not always, take ``i_rwsem``, depending on what it finds.
504504

505505
Each of these, or the functions which call them, need to be alert to
@@ -1196,29 +1196,26 @@ potentially need to call ``link_path_walk()`` again and again on
11961196
successive symlinks until one is found that doesn't point to another
11971197
symlink.
11981198

1199-
This case is handled by the relevant caller of ``link_path_walk()``, such as
1200-
``path_lookupat()`` using a loop that calls ``link_path_walk()``, and then
1201-
handles the final component. If the final component is a symlink
1202-
that needs to be followed, then ``trailing_symlink()`` is called to set
1203-
things up properly and the loop repeats, calling ``link_path_walk()``
1204-
again. This could loop as many as 40 times if the last component of
1205-
each symlink is another symlink.
1206-
1207-
The various functions that examine the final component and possibly
1208-
report that it is a symlink are ``lookup_last()``, ``mountpoint_last()``
1209-
and ``do_last()``, each of which use the same convention as
1210-
``walk_component()`` of returning ``1`` if a symlink was found that needs
1211-
to be followed.
1212-
1213-
Of these, ``do_last()`` is the most interesting as it is used for
1214-
opening a file. Part of ``do_last()`` runs with ``i_rwsem`` held and this
1215-
part is in a separate function: ``lookup_open()``.
1216-
1217-
Explaining ``do_last()`` completely is beyond the scope of this article,
1218-
but a few highlights should help those interested in exploring the
1219-
code.
1220-
1221-
1. Rather than just finding the target file, ``do_last()`` needs to open
1199+
This case is handled by relevant callers of ``link_path_walk()``, such as
1200+
``path_lookupat()``, ``path_openat()`` using a loop that calls ``link_path_walk()``,
1201+
and then handles the final component by calling ``open_last_lookups()`` or
1202+
``lookup_last()``. If it is a symlink that needs to be followed,
1203+
``open_last_lookups()`` or ``lookup_last()`` will set things up properly and
1204+
return the path so that the loop repeats, calling
1205+
``link_path_walk()`` again. This could loop as many as 40 times if the last
1206+
component of each symlink is another symlink.
1207+
1208+
Of the various functions that examine the final component,
1209+
``open_last_lookups()`` is the most interesting as it works in tandem
1210+
with ``do_open()`` for opening a file. Part of ``open_last_lookups()`` runs
1211+
with ``i_rwsem`` held and this part is in a separate function: ``lookup_open()``.
1212+
1213+
Explaining ``open_last_lookups()`` and ``do_open()`` completely is beyond the scope
1214+
of this article, but a few highlights should help those interested in exploring
1215+
the code.
1216+
1217+
1. Rather than just finding the target file, ``do_open()`` is used after
1218+
``open_last_lookup()`` to open
12221219
it. If the file was found in the dcache, then ``vfs_open()`` is used for
12231220
this. If not, then ``lookup_open()`` will either call ``atomic_open()`` (if
12241221
the filesystem provides it) to combine the final lookup with the open, or

0 commit comments

Comments
 (0)