30 Dec, 2020

3 commits

  • commit 950cc0d2bef078e1f6459900ca4d4b2a2e0e3c37 upstream.

    The handle_inode_event() interface was added as (quoting comment):
    "a simple variant of handle_event() for groups that only have inode
    marks and don't have ignore mask".

    In other words, all backends except fanotify. The inotify backend
    also falls under this category, but because it required extra arguments
    it was left out of the initial pass of backends conversion to the
    simple interface.

    This results in code duplication between the generic helper
    fsnotify_handle_event() and the inotify_handle_event() callback
    which also happen to be buggy code.

    Generalize the handle_inode_event() arguments and add the check for
    FS_EXCL_UNLINK flag to the generic helper, so inotify backend could
    be converted to use the simple interface.

    Link: https://lore.kernel.org/r/20201202120713.702387-2-amir73il@gmail.com
    CC: stable@vger.kernel.org
    Fixes: b9a1b9772509 ("fsnotify: create method handle_inode_event() in fsnotify_operations")
    Signed-off-by: Amir Goldstein
    Signed-off-by: Jan Kara
    Signed-off-by: Greg Kroah-Hartman

    Amir Goldstein
     
  • [ Upstream commit ca9364dde50daba93eff711b4b945fd08beafcc2 ]

    Since commit b4868b44c5628 ("NFSv4: Wait for stateid updates after
    CLOSE/OPEN_DOWNGRADE"), every inter server copy operation suffers 5
    seconds delay regardless of the size of the copy. The delay is from
    nfs_set_open_stateid_locked when the check by nfs_stateid_is_sequential
    fails because the seqid in both nfs4_state and nfs4_stateid are 0.

    Fix by modifying nfs4_init_cp_state to return the stateid with seqid 1
    instead of 0. This is also to conform with section 4.8 of RFC 7862.

    Here is the relevant paragraph from section 4.8 of RFC 7862:

    A copy offload stateid's seqid MUST NOT be zero. In the context of a
    copy offload operation, it is inappropriate to indicate "the most
    recent copy offload operation" using a stateid with a seqid of zero
    (see Section 8.2.2 of [RFC5661]). It is inappropriate because the
    stateid refers to internal state in the server and there may be
    several asynchronous COPY operations being performed in parallel on
    the same file by the server. Therefore, a copy offload stateid with
    a seqid of zero MUST be considered invalid.

    Fixes: ce0887ac96d3 ("NFSD add nfs4 inter ssc to nfsd4_copy")
    Signed-off-by: Dai Ngo
    Signed-off-by: Chuck Lever
    Signed-off-by: Sasha Levin

    Dai Ngo
     
  • [ Upstream commit 4420440c57892779f265108f46f83832a88ca795 ]

    The warning message from nfsd terminating normally
    can confuse system adminstrators or monitoring software.

    Though it's not exactly fair to pin-point a commit where it
    originated, the current form in the current place started
    to appear in:

    Fixes: e096bbc6488d ("knfsd: remove special handling for SIGHUP")
    Signed-off-by: kazuo ito
    Signed-off-by: Chuck Lever
    Signed-off-by: Sasha Levin

    kazuo ito
     

06 Nov, 2020

4 commits


23 Oct, 2020

1 commit

  • Pull nfsd updates from Bruce Fields:
    "The one new feature this time, from Anna Schumaker, is READ_PLUS,
    which has the same arguments as READ but allows the server to return
    an array of data and hole extents.

    Otherwise it's a lot of cleanup and bugfixes"

    * tag 'nfsd-5.10' of git://linux-nfs.org/~bfields/linux: (43 commits)
    NFSv4.2: Fix NFS4ERR_STALE error when doing inter server copy
    SUNRPC: fix copying of multiple pages in gss_read_proxy_verf()
    sunrpc: raise kernel RPC channel buffer size
    svcrdma: fix bounce buffers for unaligned offsets and multiple pages
    nfsd: remove unneeded break
    net/sunrpc: Fix return value for sysctl sunrpc.transports
    NFSD: Encode a full READ_PLUS reply
    NFSD: Return both a hole and a data segment
    NFSD: Add READ_PLUS hole segment encoding
    NFSD: Add READ_PLUS data support
    NFSD: Hoist status code encoding into XDR encoder functions
    NFSD: Map nfserr_wrongsec outside of nfsd_dispatch
    NFSD: Remove the RETURN_STATUS() macro
    NFSD: Call NFSv2 encoders on error returns
    NFSD: Fix .pc_release method for NFSv2
    NFSD: Remove vestigial typedefs
    NFSD: Refactor nfsd_dispatch() error paths
    NFSD: Clean up nfsd_dispatch() variables
    NFSD: Clean up stale comments in nfsd_dispatch()
    NFSD: Clean up switch statement in nfsd_dispatch()
    ...

    Linus Torvalds
     

21 Oct, 2020

1 commit

  • NFS_FS=y as dependency of CONFIG_NFSD_V4_2_INTER_SSC still have
    build errors and some configs with NFSD=m to get NFS4ERR_STALE
    error when doing inter server copy.

    Added ops table in nfs_common for knfsd to access NFS client modules.

    Fixes: 3ac3711adb88 ("NFSD: Fix NFS server build errors")
    Signed-off-by: Dai Ngo
    Signed-off-by: J. Bruce Fields

    Dai Ngo
     

17 Oct, 2020

1 commit


12 Oct, 2020

5 commits

  • Reply to the client with multiple hole and data segments. I use the
    result of the first vfs_llseek() call for encoding as an optimization so
    we don't have to immediately repeat the call. This also lets us encode
    any remaining reply as data if we get an unexpected result while trying
    to calculate a hole.

    Signed-off-by: Anna Schumaker
    Signed-off-by: J. Bruce Fields

    Anna Schumaker
     
  • But only one of each right now. We'll expand on this in the next patch.

    Signed-off-by: Anna Schumaker
    Signed-off-by: J. Bruce Fields

    Anna Schumaker
     
  • However, we still only reply to the READ_PLUS call with a single segment
    at this time.

    Signed-off-by: Anna Schumaker
    Signed-off-by: J. Bruce Fields

    Anna Schumaker
     
  • This patch adds READ_PLUS support for returning a single
    NFS4_CONTENT_DATA segment to the client. This is basically the same as
    the READ operation, only with the extra information about data segments.

    Signed-off-by: Anna Schumaker
    Signed-off-by: J. Bruce Fields

    Anna Schumaker
     
  • The original intent was presumably to reduce code duplication. The
    trade-off was:

    - No support for an NFSD proc function returning a non-success
    RPC accept_stat value.
    - No support for void NFS replies to non-NULL procedures.
    - Everyone pays for the deduplication with a few extra conditional
    branches in a hot path.

    In addition, nfsd_dispatch() leaves *statp uninitialized in the
    success path, unlike svc_generic_dispatch().

    Address all of these problems by moving the logic for encoding
    the NFS status code into the NFS XDR encoders themselves. Then
    update the NFS .pc_func methods to return an RPC accept_stat
    value.

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     

02 Oct, 2020

12 commits


26 Sep, 2020

13 commits

  • Since only the v4 code cares about it, maybe it's better to leave
    rq_lease_breaker out of the common dispatch code?

    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • There are actually rare races where this is possible (e.g. if a new open
    intervenes between the read of i_writecount and the fi_fds).

    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • The nfsd open code has always kept separate read-only, read-write, and
    write-only opens as necessary to ensure that when a client closes or
    downgrades, we don't retain more access than necessary.

    Also, I didn't realize the cache behaved this way when I wrote
    94415b06eb8a "nfsd4: a client's own opens needn't prevent delegations".
    There I assumed fi_fds[O_WRONLY] and fi_fds[O_RDWR] would always be
    distinct. The violation of that assumption is triggering a
    WARN_ON_ONCE() and could also cause the server to give out a delegation
    when it shouldn't.

    Fixes: 94415b06eb8a ("nfsd4: a client's own opens needn't prevent delegations")
    Tested-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • silence nfscache allocation warnings with kvzalloc

    Currently nfsd_reply_cache_init attempts hash table allocation through
    kmalloc, and manually falls back to vzalloc if that fails. This makes
    the code a little larger than needed, and creates a significant amount
    of serial console spam if you have enough systems.

    Switching to kvzalloc gets rid of the allocation warnings, and makes
    the code a little cleaner too as a side effect.

    Freeing of nn->drc_hashtbl is already done using kvfree currently.

    Signed-off-by: Rik van Riel
    Signed-off-by: J. Bruce Fields

    Rik van Riel
     
  • Fixes coccicheck warning:

    fs/nfsd/nfs4proc.c:3234:5-29: WARNING: Comparison to bool

    Signed-off-by: Zheng Bin
    Signed-off-by: J. Bruce Fields

    Zheng Bin
     
  • Squelch some sparse warnings:

    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:1860:16: warning: incorrect type in assignment (different base types)
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:1860:16: expected int status
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:1860:16: got restricted __be32
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:1862:24: warning: incorrect type in return expression (different base types)
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:1862:24: expected restricted __be32
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:1862:24: got int status

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Squelch some sparse warnings:

    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4692:24: warning: incorrect type in return expression (different base types)
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4692:24: expected int
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4692:24: got restricted __be32 [usertype]
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4702:32: warning: incorrect type in return expression (different base types)
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4702:32: expected int
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4702:32: got restricted __be32 [usertype]
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4739:13: warning: incorrect type in assignment (different base types)
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4739:13: expected restricted __be32 [usertype] err
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4739:13: got int
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4891:15: warning: incorrect type in assignment (different base types)
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4891:15: expected unsigned int [assigned] [usertype] count
    /home/cel/src/linux/linux/fs/nfsd/nfs4xdr.c:4891:15: got restricted __be32 [usertype]

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Squelch some sparse warnings:

    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2264:13: warning: incorrect type in assignment (different base types)
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2264:13: expected int err
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2264:13: got restricted __be32
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2266:24: warning: incorrect type in return expression (different base types)
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2266:24: expected restricted __be32
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2266:24: got int err
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2288:13: warning: incorrect type in assignment (different base types)
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2288:13: expected int err
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2288:13: got restricted __be32
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2290:24: warning: incorrect type in return expression (different base types)
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2290:24: expected restricted __be32
    /home/cel/src/linux/linux/fs/nfsd/vfs.c:2290:24: got int err

    Signed-off-by: Chuck Lever
    Signed-off-by: J. Bruce Fields

    Chuck Lever
     
  • Reserving space for a large READ payload requires special handling when
    reserving space in the xdr buffer pages. One problem we can have is use
    of the scratch buffer, which is used to get a pointer to a contiguous
    region of data up to PAGE_SIZE. When using the scratch buffer, calls to
    xdr_commit_encode() shift the data to it's proper alignment in the xdr
    buffer. If we've reserved several pages in a vector, then this could
    potentially invalidate earlier pointers and result in incorrect READ
    data being sent to the client.

    I get around this by looking at the amount of space left in the current
    page, and never reserve more than that for each entry in the read
    vector. This lets us place data directly where it needs to go in the
    buffer pages.

    Signed-off-by: Anna Schumaker
    Signed-off-by: J. Bruce Fields

    Anna Schumaker
     
  • Now when a read delegation is given, two delegation related traces
    will be printed:

    nfsd_deleg_open: client 5f45b854:e6058001 stateid 00000030:00000001
    nfsd_deleg_none: client 5f45b854:e6058001 stateid 0000002f:00000001

    Although the intention is to let developers know two stateid are
    returned, the traces are confusing about whether or not a read delegation
    is handled out. So renaming trace_nfsd_deleg_none() to trace_nfsd_open()
    and trace_nfsd_deleg_open() to trace_nfsd_deleg_read() to make
    the intension clearer.

    The patched traces will be:

    nfsd_deleg_read: client 5f48a967:b55b21cd stateid 00000003:00000001
    nfsd_open: client 5f48a967:b55b21cd stateid 00000002:00000001

    Suggested-by: Chuck Lever
    Signed-off-by: Hou Tao
    Signed-off-by: J. Bruce Fields

    Hou Tao
     
  • In nfsd4_encode_listxattrs(), the variable p is assigned to at one point
    but this value is never used before p is reassigned. Fix this.

    Addresses-Coverity: ("Unused value")
    Signed-off-by: Alex Dewar
    Signed-off-by: J. Bruce Fields

    Alex Dewar
     
  • Missing "is".

    Signed-off-by: Alex Dewar
    Signed-off-by: J. Bruce Fields

    Alex Dewar
     
  • The delegation is no longer returnable, so I don't think there's much
    point retrying the recall.

    (I think it's worth asking why we even need separate CLOSED_DELEG and
    REVOKED_DELEG states. But treating them the same would currently cause
    nfsd4_free_stateid to call list_del_init(&dp->dl_recall_lru) on a
    delegation that the laundromat had unhashed but not revoked, incorrectly
    removing it from the laundromat's reaplist or a client's dl_recall_lru.)

    Signed-off-by: J. Bruce Fields

    J. Bruce Fields