<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/nfs/dir.c, branch linux-6.10.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.10.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.10.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2024-05-30T20:17:12Z</updated>
<entry>
<title>NFS: add barriers when testing for NFS_FSDATA_BLOCKED</title>
<updated>2024-05-30T20:17:12Z</updated>
<author>
<name>NeilBrown</name>
</author>
<published>2024-05-28T03:27:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=99bc9f2eb3f79a2b4296d9bf43153e1d10ca50d3'/>
<id>urn:sha1:99bc9f2eb3f79a2b4296d9bf43153e1d10ca50d3</id>
<content type='text'>
dentry-&gt;d_fsdata is set to NFS_FSDATA_BLOCKED while unlinking or
renaming-over a file to ensure that no open succeeds while the NFS
operation progressed on the server.

Setting dentry-&gt;d_fsdata to NFS_FSDATA_BLOCKED is done under -&gt;d_lock
after checking the refcount is not elevated.  Any attempt to open the
file (through that name) will go through lookp_open() which will take
-&gt;d_lock while incrementing the refcount, we can be sure that once the
new value is set, __nfs_lookup_revalidate() *will* see the new value and
will block.

We don't have any locking guarantee that when we set -&gt;d_fsdata to NULL,
the wait_var_event() in __nfs_lookup_revalidate() will notice.
wait/wake primitives do NOT provide barriers to guarantee order.  We
must use smp_load_acquire() in wait_var_event() to ensure we look at an
up-to-date value, and must use smp_store_release() before wake_up_var().

This patch adds those barrier functions and factors out
block_revalidate() and unblock_revalidate() far clarity.

There is also a hypothetical bug in that if memory allocation fails
(which never happens in practice) we might leave -&gt;d_fsdata locked.
This patch adds the missing call to unblock_revalidate().

Reported-and-tested-by: Richard Kojedzinszky &lt;richard+debian+bugreport@kojedz.in&gt;
Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1071501
Fixes: 3c59366c207e ("NFS: don't unhash dentry during unlink/rename")
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
</content>
</entry>
<entry>
<title>NFS: abort nfs_atomic_open_v23 if name is too long.</title>
<updated>2024-05-30T20:12:11Z</updated>
<author>
<name>NeilBrown</name>
</author>
<published>2024-05-28T23:11:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=296f4ce81d08e73c22408c49f4938a85bd075e5c'/>
<id>urn:sha1:296f4ce81d08e73c22408c49f4938a85bd075e5c</id>
<content type='text'>
An attempt to open a file with a name longer than NFS3_MAXNAMLEN will
trigger a WARN_ON_ONCE in encode_filename3() because
nfs_atomic_open_v23() doesn't have the test on -&gt;d_name.len that
nfs_atomic_open() has.

So add that test.

Reported-by: James Clark &lt;james.clark@arm.com&gt;
Closes: https://lore.kernel.org/all/20240528105249.69200-1-james.clark@arm.com/
Fixes: 7c6c5249f061 ("NFS: add atomic_open for NFSv3 to handle O_TRUNC correctly.")
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
</content>
</entry>
<entry>
<title>nfs: don't invalidate dentries on transient errors</title>
<updated>2024-05-24T16:31:11Z</updated>
<author>
<name>Scott Mayhew</name>
</author>
<published>2024-05-23T19:01:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0c8c7c559740d2d8b66048162af6c4dba8f0c88c'/>
<id>urn:sha1:0c8c7c559740d2d8b66048162af6c4dba8f0c88c</id>
<content type='text'>
This is a slight variation on a patch previously proposed by Neil Brown
that never got merged.

Prior to commit 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()"),
any error from nfs_lookup_verify_inode() other than -ESTALE would result
in nfs_lookup_revalidate() returning that error (-ESTALE is mapped to
zero).

Since that commit, all errors result in nfs_lookup_revalidate()
returning zero, resulting in dentries being invalidated where they
previously were not (particularly in the case of -ERESTARTSYS).

Fix it by passing the actual error code to nfs_lookup_revalidate_done(),
and leaving the decision on whether to  map the error code to zero or
one to nfs_lookup_revalidate_done().

A simple reproducer is to run the following python code in a
subdirectory of an NFS mount (not in the root of the NFS mount):

---8&lt;---
import os
import multiprocessing
import time

if __name__=="__main__":
    multiprocessing.set_start_method("spawn")

    count = 0
    while True:
        try:
            os.getcwd()
            pool = multiprocessing.Pool(10)
            pool.close()
            pool.terminate()
            count += 1
        except Exception as e:
            print(f"Failed after {count} iterations")
            print(e)
            break
---8&lt;---

Prior to commit 5ceb9d7fdaaf, the above code would run indefinitely.
After commit 5ceb9d7fdaaf, it fails almost immediately with -ENOENT.

Signed-off-by: Scott Mayhew &lt;smayhew@redhat.com&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
</content>
</entry>
<entry>
<title>NFS: add atomic_open for NFSv3 to handle O_TRUNC correctly.</title>
<updated>2024-05-20T15:09:20Z</updated>
<author>
<name>NeilBrown</name>
</author>
<published>2024-03-25T05:36:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7c6c5249f061b64fc6b5b90bc147169a048691bf'/>
<id>urn:sha1:7c6c5249f061b64fc6b5b90bc147169a048691bf</id>
<content type='text'>
With two clients, each with NFSv3 mounts of the same directory, the sequence:

   client1            client2
  ls -l afile
                      echo hello there &gt; afile
  echo HELLO &gt; afile
  cat afile

will show
   HELLO
   there

because the O_TRUNC requested in the final 'echo' doesn't take effect.
This is because the "Negative dentry, just create a file" section in
lookup_open() assumes that the file *does* get created since the dentry
was negative, so it sets FMODE_CREATED, and this causes do_open() to
clear O_TRUNC and so the file doesn't get truncated.

Even mounting with -o lookupcache=none does not help as
nfs_neg_need_reval() always returns false if LOOKUP_CREATE is set.

This patch fixes the problem by providing an atomic_open inode operation
for NFSv3 (and v2).  The code is largely the code from the branch in
lookup_open() when atomic_open is not provided.  The significant change
is that the O_TRUNC flag is passed a new nfs_do_create() which add
'trunc' handling to nfs_create().

With this change we also optimise away an unnecessary LOOKUP before the
file is created.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
</content>
</entry>
<entry>
<title>nfs: make nfs_set_verifier() safe for use in RCU pathwalk</title>
<updated>2024-02-25T07:10:31Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2023-09-28T01:50:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=10a973fc4fb22390a8d362dd3265ec2c9a81d84c'/>
<id>urn:sha1:10a973fc4fb22390a8d362dd3265ec2c9a81d84c</id>
<content type='text'>
nfs_set_verifier() relies upon dentry being pinned; if that's
the case, grabbing -&gt;d_lock stabilizes -&gt;d_parent and guarantees
that -&gt;d_parent points to a positive dentry.  For something
we'd run into in RCU mode that is *not* true - dentry might've
been through dentry_kill() just as we grabbed -&gt;d_lock, with
its parent going through the same just as we get to into
nfs_set_verifier_locked().  It might get to detaching inode
(and zeroing -&gt;d_inode) before nfs_set_verifier_locked() gets
to fetching that; we get an oops as the result.

That can happen in nfs{,4} -&gt;d_revalidate(); the call chain in
question is nfs_set_verifier_locked() &lt;- nfs_set_verifier() &lt;-
nfs_lookup_revalidate_delegated() &lt;- nfs{,4}_do_lookup_revalidate().
We have checked that the parent had been positive, but that's
done before we get to nfs_set_verifier() and it's possible for
memory pressure to pick our dentry as eviction candidate by that
time.  If that happens, back-to-back attempts to kill dentry and
its parent are quite normal.  Sure, in case of eviction we'll
fail the -&gt;d_seq check in the caller, but we need to survive
until we return there...

Acked-by: Christian Brauner &lt;brauner@kernel.org&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>nfs: add new tracepoint at nfs4 revalidate entry point</title>
<updated>2024-01-04T15:47:56Z</updated>
<author>
<name>Jeff Layton</name>
</author>
<published>2023-11-03T10:10:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=283064fca3e8c6a2f3d1d70bb56f5c01ee01118c'/>
<id>urn:sha1:283064fca3e8c6a2f3d1d70bb56f5c01ee01118c</id>
<content type='text'>
Add a call to the v4 d_revalidate entrypoint, just like the v3 one.

Signed-off-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Reviewed-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Use parent's objective cred in nfs_access_login_time()</title>
<updated>2024-01-04T15:47:56Z</updated>
<author>
<name>Scott Mayhew</name>
</author>
<published>2023-12-05T14:10:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a10a9233073d984b239e22358ba21825e27e2e88'/>
<id>urn:sha1:a10a9233073d984b239e22358ba21825e27e2e88</id>
<content type='text'>
The subjective cred (task-&gt;cred) can potentially be overridden and
subsquently freed in non-RCU context, which could lead to a panic if we
try to use it in cred_fscmp().  Use __task_cred(), which returns the
objective cred (task-&gt;real_cred) instead.

Fixes: 0eb43812c027 ("NFS: Clear the file access cache upon login")
Fixes: 5e9a7b9c2ea1 ("NFS: Fix up a sparse warning")

Signed-off-by: Scott Mayhew &lt;smayhew@redhat.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>nfs: Convert nfs_symlink() to use a folio</title>
<updated>2023-11-01T19:40:44Z</updated>
<author>
<name>Matthew Wilcox (Oracle)</name>
</author>
<published>2023-09-15T17:33:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f003a717ae9086b1e8a4663124a96862df7282e7'/>
<id>urn:sha1:f003a717ae9086b1e8a4663124a96862df7282e7</id>
<content type='text'>
Use the folio APIs, saving about four calls to compound_head().
Convert back to a page in each of the individual protocol implementations.

Signed-off-by: Matthew Wilcox (Oracle) &lt;willy@infradead.org&gt;
Signed-off-by: Trond Myklebust &lt;trond.myklebust@hammerspace.com&gt;
</content>
</entry>
<entry>
<title>nfs: fix redundant readdir request after get eof</title>
<updated>2023-08-24T17:24:15Z</updated>
<author>
<name>Kinglong Mee</name>
</author>
<published>2023-07-21T01:23:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=14e7316a3c73cf45cef4422549f3585fc1c53521'/>
<id>urn:sha1:14e7316a3c73cf45cef4422549f3585fc1c53521</id>
<content type='text'>
When a directory contains 17 files (except . and ..), nfs client sends
a redundant readdir request after get eof.

A simple reproduce,
At NFS server, create a directory with 17 files under exported directory.
 # mkdir test
 # cd test
 # for i in {0..16}  ; do touch $i; done

At NFS client, no matter mounting through nfsv3 or nfsv4,
does ls (or ll) at the created test directory.

A tshark output likes following (for nfsv4),

 # tshark -i eth0 tcp port 2049 -Tfields -e ip.src -e ip.dst -e nfs -e nfs.cookie4

srcip   dstip   SEQUENCE, PUTFH, READDIR        0
dstip   srcip   SEQUENCE PUTFH READDIR  909539109313539306,2108391201987888856,2305312124304486544,2566335452463141496,2978225129081509984,4263037479923412583,4304697173036510679,4666703455469210097,4759208201298769007,4776701232145978803,5338408478512081262,5949498658935544804,5971526429894832903,6294060338267709855,6528840566229532529,8600463293536422524,9223372036854775807
srcip   dstip
srcip   dstip   SEQUENCE, PUTFH, READDIR        9223372036854775807
dstip   srcip   SEQUENCE PUTFH READDIR

The READDIR with cookie 9223372036854775807(0x7FFFFFFFFFFFFFFF) is redundant.

Reviewed-by: Benjamin Coddington &lt;bcodding@redhat.com&gt;
Signed-off-by: Kinglong Mee &lt;kinglongmee@gmail.com&gt;
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
<entry>
<title>NFS: Convert kmap_atomic() to kmap_local_folio()</title>
<updated>2023-05-19T20:50:05Z</updated>
<author>
<name>Fabio M. De Francesco</name>
</author>
<published>2023-05-03T17:24:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b71e2416ec4cb3edd6c667243bce357b0c6f7b3'/>
<id>urn:sha1:4b71e2416ec4cb3edd6c667243bce357b0c6f7b3</id>
<content type='text'>
kmap_atomic() is deprecated in favor of kmap_local_{folio,page}().

Therefore, replace kmap_atomic() with kmap_local_folio() in
nfs_readdir_folio_array_append().

kmap_atomic() disables page-faults and preemption (the latter only for
!PREEMPT_RT kernels), However, the code within the mapping/un-mapping in
nfs_readdir_folio_array_append() does not depend on the above-mentioned
side effects.

Therefore, a mere replacement of the old API with the new one is all that
is required (i.e., there is no need to explicitly add any calls to
pagefault_disable() and/or preempt_disable()).

Tested with (x)fstests in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel
with HIGHMEM64GB enabled.

Cc: Ira Weiny &lt;ira.weiny@intel.com&gt;
Signed-off-by: Fabio M. De Francesco &lt;fmdefrancesco@gmail.com&gt;
Fixes: ec108d3cc766 ("NFS: Convert readdir page array functions to use a folio")
Signed-off-by: Anna Schumaker &lt;Anna.Schumaker@Netapp.com&gt;
</content>
</entry>
</feed>
