History

Merge tag 'nfs-for-6.19-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs

Pull NFS client updates from Trond Myklebust: "Bugfixes: - Fix 'nlink' attribute update races when unlinking a file - Add missing initialisers for the directory verifier in various places - Don't regress the NFSv4 open state due to misordered racing replies - Ensure the NFSv4.x callback server uses the correct transport connection - Fix potential use-after-free races when shutting down the NFSv4.x callback server - Fix a pNFS layout commit crash - Assorted fixes to ensure correct propagation of mount options when the client crosses a filesystem boundary and triggers the VFS automount code - More localio fixes Features and cleanups: - Add initial support for basic directory delegations - SunRPC back channel code cleanups" * tag 'nfs-for-6.19-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (24 commits) NFSv4: Handle NFS4ERR_NOTSUPP errors for directory delegations nfs/localio: remove 61 byte hole from needless ____cacheline_aligned nfs/localio: remove alignment size checking in nfs_is_local_dio_possible NFS: Fix up the automount fs_context to use the correct cred NFS: Fix inheritance of the block sizes when automounting NFS: Automounted filesystems should inherit ro,noexec,nodev,sync flags Revert "nfs: ignore SB_RDONLY when mounting nfs" Revert "nfs: clear SB_RDONLY before getting superblock" Revert "nfs: ignore SB_RDONLY when remounting nfs" NFS: Add a module option to disable directory delegations NFS: Shortcut lookup revalidations if we have a directory delegation NFS: Request a directory delegation during RENAME NFS: Request a directory delegation on ACCESS, CREATE, and UNLINK NFS: Add support for sending GDD_GETATTR NFSv4/pNFS: Clear NFS_INO_LAYOUTCOMMIT in pnfs_mark_layout_stateid_invalid NFSv4.1: protect destroying and nullifying bc_serv structure SUNRPC: new helper function for stopping backchannel server SUNRPC: cleanup common code in backchannel request NFSv4.1: pass transport for callback shutdown NFSv4: ensure the open stateid seqid doesn't go backwards ...

Linus Torvalds committed 11 months ago

Commit 6bb34af2 parents d358e52 bd3b04b25 files · +385 −91Browse files

Unified · Split

25 files
  1. fs/nfs/callback.c +2 −2
  2. fs/nfs/callback.h +2 −1
  3. fs/nfs/client.c +17 −4
  4. fs/nfs/delegation.c +8 −0
  5. fs/nfs/delegation.h +13 −0
  6. fs/nfs/dir.c +37 −9
  7. fs/nfs/inode.c +3 −0
  8. fs/nfs/internal.h +1 −2
  9. fs/nfs/localio.c +1 −3
  10. fs/nfs/namespace.c +15 −1
  11. fs/nfs/nfs3proc.c +2 −1
  12. fs/nfs/nfs4client.c +21 −6
  13. fs/nfs/nfs4proc.c +91 −20
  14. fs/nfs/nfs4trace.h +1 −0
  15. fs/nfs/nfs4xdr.c +106 −0
  16. fs/nfs/pnfs.c +1 −0
  17. fs/nfs/proc.c +2 −1
  18. fs/nfs/super.c +3 −30
  19. fs/nfs/unlink.c +2 −1
  20. include/linux/nfs_fs.h +1 −0
  21. include/linux/nfs_fs_sb.h +6 −0
  22. include/linux/nfs_xdr.h +9 −1
  23. include/linux/sunrpc/bc_xprt.h +7 −0
  24. net/sunrpc/backchannel_rqst.c +32 −3
  25. net/sunrpc/xprtrdma/backchannel.c +2 −6
fs/nfs/callback.c+2−2
@@ -258,7 +258,7 @@ err_start: · 257 unmodified lines
258258 /*
259259 * Kill the callback thread if it's no longer being used.
260260 */
261−void nfs_callback_down(int minorversion, struct net *net)
261+void nfs_callback_down(int minorversion, struct net *net, struct rpc_xprt *xprt)
262262 {
263263 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
264264 struct svc_serv *serv;
@@ -270,7 +270,7 @@ void nfs_callback_down(int minorversion, struct net *net) · 5 unmodified lines
270270 if (cb_info->users == 0) {
271271 svc_set_num_threads(serv, NULL, 0);
272272 dprintk("nfs_callback_down: service destroyed\n");
273− svc_destroy(&cb_info->serv);
273+ xprt_svc_destroy_nullify_bc(xprt, &cb_info->serv);
274274 }
275275 mutex_unlock(&nfs_callback_mutex);
276276 }
fs/nfs/callback.h+2−1
@@ -188,7 +188,8 @@ extern __be32 nfs4_callback_recall(void *argp, void *resp, · 187 unmodified lines
188188 struct cb_process_state *cps);
189189 #if IS_ENABLED(CONFIG_NFS_V4)
190190 extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
191−extern void nfs_callback_down(int minorversion, struct net *net);
191+extern void nfs_callback_down(int minorversion, struct net *net,
192+ struct rpc_xprt *xprt);
192193 #endif /* CONFIG_NFS_V4 */
193194 /*
194195 * nfs41: Callbacks are expected to not cause substantial latency,
fs/nfs/client.c+17−4
@@ -784,10 +784,18 @@ static int nfs_init_server(struct nfs_server *server, · 783 unmodified lines
784784 server->fattr_valid = NFS_ATTR_FATTR_V4;
785785 }
786786
787− if (ctx->rsize)
787+ if (ctx->bsize) {
788+ server->bsize = ctx->bsize;
789+ server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_BSIZE;
790+ }
791+ if (ctx->rsize) {
788792 server->rsize = nfs_io_size(ctx->rsize, clp->cl_proto);
789− if (ctx->wsize)
793+ server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_RSIZE;
794+ }
795+ if (ctx->wsize) {
790796 server->wsize = nfs_io_size(ctx->wsize, clp->cl_proto);
797+ server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_WSIZE;
798+ }
791799
792800 server->acregmin = ctx->acregmin * HZ;
793801 server->acregmax = ctx->acregmax * HZ;
@@ -977,8 +985,13 @@ EXPORT_SYMBOL_GPL(nfs_probe_server); · 183 unmodified lines
977985 void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *source)
978986 {
979987 target->flags = source->flags;
980− target->rsize = source->rsize;
981− target->wsize = source->wsize;
988+ target->automount_inherit = source->automount_inherit;
989+ if (source->automount_inherit & NFS_AUTOMOUNT_INHERIT_BSIZE)
990+ target->bsize = source->bsize;
991+ if (source->automount_inherit & NFS_AUTOMOUNT_INHERIT_RSIZE)
992+ target->rsize = source->rsize;
993+ if (source->automount_inherit & NFS_AUTOMOUNT_INHERIT_WSIZE)
994+ target->wsize = source->wsize;
982995 target->acregmin = source->acregmin;
983996 target->acregmax = source->acregmax;
984997 target->acdirmin = source->acdirmin;
fs/nfs/delegation.c+8−0
@@ -30,6 +30,11 @@ · 29 unmodified lines
3030 static unsigned nfs_delegation_watermark = NFS_DEFAULT_DELEGATION_WATERMARK;
3131 module_param_named(delegation_watermark, nfs_delegation_watermark, uint, 0644);
3232
33+bool directory_delegations = true;
34+module_param(directory_delegations, bool, 0644);
35+MODULE_PARM_DESC(directory_delegations,
36+ "Enable the use of directory delegations, defaults to on.");
37+
3338 static struct hlist_head *nfs_delegation_hash(struct nfs_server *server,
3439 const struct nfs_fh *fhandle)
3540 {
@@ -143,6 +148,8 @@ static int nfs4_do_check_delegation(struct inode *inode, fmode_t type, · 107 unmodified lines
143148 */
144149 int nfs4_have_delegation(struct inode *inode, fmode_t type, int flags)
145150 {
151+ if (S_ISDIR(inode->i_mode) && !directory_delegations)
152+ nfs_inode_evict_delegation(inode);
146153 return nfs4_do_check_delegation(inode, type, flags, true);
147154 }
148155
@@ -379,6 +386,7 @@ nfs_detach_delegation_locked(struct nfs_inode *nfsi, · 230 unmodified lines
379386 delegation->inode = NULL;
380387 rcu_assign_pointer(nfsi->delegation, NULL);
381388 spin_unlock(&delegation->lock);
389+ clear_bit(NFS_INO_REQ_DIR_DELEG, &nfsi->flags);
382390 return delegation;
383391 }
384392
fs/nfs/delegation.h+13−0
@@ -124,6 +124,19 @@ static inline int nfs_have_delegated_mtime(struct inode *inode) · 123 unmodified lines
124124 NFS_DELEGATION_FLAG_TIME);
125125 }
126126
127+extern bool directory_delegations;
128+
129+static inline void nfs_request_directory_delegation(struct inode *inode)
130+{
131+ if (S_ISDIR(inode->i_mode))
132+ set_bit(NFS_INO_REQ_DIR_DELEG, &NFS_I(inode)->flags);
133+}
134+
135+static inline bool nfs_have_directory_delegation(struct inode *inode)
136+{
137+ return S_ISDIR(inode->i_mode) && nfs_have_delegated_attributes(inode);
138+}
139+
127140 int nfs4_delegation_hash_alloc(struct nfs_server *server);
128141
129142 #endif
fs/nfs/dir.c+37−9
@@ -789,16 +789,17 @@ again: · 788 unmodified lines
789789 goto out;
790790 }
791791
792+ nfs_set_verifier(dentry, dir_verifier);
792793 inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr);
793794 alias = d_splice_alias(inode, dentry);
794795 d_lookup_done(dentry);
795796 if (alias) {
796797 if (IS_ERR(alias))
797798 goto out;
799+ nfs_set_verifier(alias, dir_verifier);
798800 dput(dentry);
799801 dentry = alias;
800802 }
801− nfs_set_verifier(dentry, dir_verifier);
802803 trace_nfs_readdir_lookup(d_inode(parent), dentry, 0);
803804 out:
804805 dput(dentry);
@@ -1514,6 +1515,15 @@ static int nfs_check_verifier(struct inode *dir, struct dentry *dentry, · 709 unmodified lines
15141515 return 0;
15151516 if (!nfs_dentry_verify_change(dir, dentry))
15161517 return 0;
1518+
1519+ /*
1520+ * If we have a directory delegation then we don't need to revalidate
1521+ * the directory. The delegation will either get recalled or we will
1522+ * receive a notification when it changes.
1523+ */
1524+ if (nfs_have_directory_delegation(dir))
1525+ return 0;
1526+
15171527 /* Revalidate nfsi->cache_change_attribute before we declare a match */
15181528 if (nfs_mapping_need_revalidate_inode(dir)) {
15191529 if (rcu_walk)
@@ -1894,13 +1904,15 @@ static int nfs_dentry_delete(const struct dentry *dentry) · 374 unmodified lines
18941904 }
18951905
18961906 /* Ensure that we revalidate inode->i_nlink */
1897−static void nfs_drop_nlink(struct inode *inode)
1907+static void nfs_drop_nlink(struct inode *inode, unsigned long gencount)
18981908 {
1909+ struct nfs_inode *nfsi = NFS_I(inode);
1910+
18991911 spin_lock(&inode->i_lock);
19001912 /* drop the inode if we're reasonably sure this is the last link */
1901− if (inode->i_nlink > 0)
1913+ if (inode->i_nlink > 0 && gencount == nfsi->attr_gencount)
19021914 drop_nlink(inode);
1903− NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
1915+ nfsi->attr_gencount = nfs_inc_attr_generation_counter();
19041916 nfs_set_cache_invalid(
19051917 inode, NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME |
19061918 NFS_INO_INVALID_NLINK);
@@ -1914,8 +1926,9 @@ static void nfs_drop_nlink(struct inode *inode) · 7 unmodified lines
19141926 static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
19151927 {
19161928 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
1929+ unsigned long gencount = READ_ONCE(NFS_I(inode)->attr_gencount);
19171930 nfs_complete_unlink(dentry, inode);
1918− nfs_drop_nlink(inode);
1931+ nfs_drop_nlink(inode, gencount);
19191932 }
19201933 iput(inode);
19211934 }
@@ -1991,13 +2004,14 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in · 69 unmodified lines
19912004 nfs_lookup_advise_force_readdirplus(dir, flags);
19922005
19932006 no_entry:
2007+ nfs_set_verifier(dentry, dir_verifier);
19942008 res = d_splice_alias(inode, dentry);
19952009 if (res != NULL) {
19962010 if (IS_ERR(res))
19972011 goto out;
2012+ nfs_set_verifier(res, dir_verifier);
19982013 dentry = res;
19992014 }
2000− nfs_set_verifier(dentry, dir_verifier);
20012015 out:
20022016 trace_nfs_lookup_exit(dir, dentry, flags, PTR_ERR_OR_ZERO(res));
20032017 nfs_free_fattr(fattr);
@@ -2139,12 +2153,12 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry, · 135 unmodified lines
21392153 d_drop(dentry);
21402154 switch (err) {
21412155 case -ENOENT:
2142− d_splice_alias(NULL, dentry);
21432156 if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE))
21442157 dir_verifier = inode_peek_iversion_raw(dir);
21452158 else
21462159 dir_verifier = nfs_save_change_attribute(dir);
21472160 nfs_set_verifier(dentry, dir_verifier);
2161+ d_splice_alias(NULL, dentry);
21482162 break;
21492163 case -EISDIR:
21502164 case -ENOTDIR:
@@ -2202,6 +2216,13 @@ no_open: · 51 unmodified lines
22022216 }
22032217 EXPORT_SYMBOL_GPL(nfs_atomic_open);
22042218
2219+static int
2220+nfs_lookup_revalidate_delegated_parent(struct inode *dir, struct dentry *dentry,
2221+ struct inode *inode)
2222+{
2223+ return nfs_lookup_revalidate_done(dir, dentry, inode, 1);
2224+}
2225+
22052226 static int
22062227 nfs4_lookup_revalidate(struct inode *dir, const struct qstr *name,
22072228 struct dentry *dentry, unsigned int flags)
@@ -2229,6 +2250,9 @@ nfs4_lookup_revalidate(struct inode *dir, const struct qstr *name, · 21 unmodified lines
22292250 if (nfs_verifier_is_delegated(dentry))
22302251 return nfs_lookup_revalidate_delegated(dir, dentry, inode);
22312252
2253+ if (nfs_have_directory_delegation(dir))
2254+ return nfs_lookup_revalidate_delegated_parent(dir, dentry, inode);
2255+
22322256 /* NFS only supports OPEN on regular files */
22332257 if (!S_ISREG(inode->i_mode))
22342258 goto full_reval;
@@ -2507,9 +2531,11 @@ static int nfs_safe_remove(struct dentry *dentry) · 272 unmodified lines
25072531
25082532 trace_nfs_remove_enter(dir, dentry);
25092533 if (inode != NULL) {
2534+ unsigned long gencount = READ_ONCE(NFS_I(inode)->attr_gencount);
2535+
25102536 error = NFS_PROTO(dir)->remove(dir, dentry);
25112537 if (error == 0)
2512− nfs_drop_nlink(inode);
2538+ nfs_drop_nlink(inode, gencount);
25132539 } else
25142540 error = NFS_PROTO(dir)->remove(dir, dentry);
25152541 if (error == -ENOENT)
@@ -2709,6 +2735,7 @@ int nfs_rename(struct mnt_idmap *idmap, struct inode *old_dir, · 193 unmodified lines
27092735 {
27102736 struct inode *old_inode = d_inode(old_dentry);
27112737 struct inode *new_inode = d_inode(new_dentry);
2738+ unsigned long new_gencount = 0;
27122739 struct dentry *dentry = NULL;
27132740 struct rpc_task *task;
27142741 bool must_unblock = false;
@@ -2761,6 +2788,7 @@ int nfs_rename(struct mnt_idmap *idmap, struct inode *old_dir, · 46 unmodified lines
27612788 } else {
27622789 block_revalidate(new_dentry);
27632790 must_unblock = true;
2791+ new_gencount = NFS_I(new_inode)->attr_gencount;
27642792 spin_unlock(&new_dentry->d_lock);
27652793 }
27662794
@@ -2800,7 +2828,7 @@ out: · 33 unmodified lines
28002828 new_dir, new_dentry, error);
28012829 if (!error) {
28022830 if (new_inode != NULL)
2803− nfs_drop_nlink(new_inode);
2831+ nfs_drop_nlink(new_inode, new_gencount);
28042832 /*
28052833 * The d_move() should be here instead of in an async RPC completion
28062834 * handler because we need the proper locks to move the dentry. If
fs/nfs/inode.c+3−0
@@ -1389,6 +1389,9 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) · 1388 unmodified lines
13891389 status = pnfs_sync_inode(inode, false);
13901390 if (status)
13911391 goto out;
1392+ } else if (nfs_have_directory_delegation(inode)) {
1393+ status = 0;
1394+ goto out;
13921395 }
13931396
13941397 status = -ENOMEM;
fs/nfs/internal.h+1−2
@@ -13,7 +13,7 @@ · 12 unmodified lines
1313 #include <linux/nfslocalio.h>
1414 #include <linux/wait_bit.h>
1515
16−#define NFS_SB_MASK (SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS)
16+#define NFS_SB_MASK (SB_RDONLY|SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS)
1717
1818 extern const struct export_operations nfs_export_ops;
1919
@@ -152,7 +152,6 @@ struct nfs_fs_context { · 132 unmodified lines
152152 struct super_block *sb;
153153 struct dentry *dentry;
154154 struct nfs_fattr *fattr;
155− unsigned int inherited_bsize;
156155 } clone_data;
157156 };
158157
fs/nfs/localio.c+1−3
@@ -43,8 +43,8 @@ struct nfs_local_kiocb { · 42 unmodified lines
4343 size_t end_len;
4444 short int end_iter_index;
4545 atomic_t n_iters;
46+ struct iov_iter iters[NFSLOCAL_MAX_IOS];
4647 bool iter_is_dio_aligned[NFSLOCAL_MAX_IOS];
47− struct iov_iter iters[NFSLOCAL_MAX_IOS] ____cacheline_aligned;
4848 /* End mostly DIO-specific members */
4949 };
5050
@@ -339,8 +339,6 @@ nfs_is_local_dio_possible(struct nfs_local_kiocb *iocb, int rw, · 288 unmodified lines
339339
340340 if (unlikely(!nf_dio_mem_align || !nf_dio_offset_align))
341341 return false;
342− if (unlikely(nf_dio_offset_align > PAGE_SIZE))
343− return false;
344342 if (unlikely(len < nf_dio_offset_align))
345343 return false;
346344
fs/nfs/namespace.c+15−1
@@ -149,6 +149,7 @@ struct vfsmount *nfs_d_automount(struct path *path) · 148 unmodified lines
149149 struct vfsmount *mnt = ERR_PTR(-ENOMEM);
150150 struct nfs_server *server = NFS_SB(path->dentry->d_sb);
151151 struct nfs_client *client = server->nfs_client;
152+ unsigned long s_flags = path->dentry->d_sb->s_flags;
152153 int timeout = READ_ONCE(nfs_mountpoint_expiry_timeout);
153154 int ret;
154155
@@ -169,11 +170,21 @@ struct vfsmount *nfs_d_automount(struct path *path) · 14 unmodified lines
169170 if (!ctx->clone_data.fattr)
170171 goto out_fc;
171172
173+ if (fc->cred != server->cred) {
174+ put_cred(fc->cred);
175+ fc->cred = get_cred(server->cred);
176+ }
177+
172178 if (fc->net_ns != client->cl_net) {
173179 put_net(fc->net_ns);
174180 fc->net_ns = get_net(client->cl_net);
175181 }
176182
183+ /* Inherit the flags covered by NFS_SB_MASK */
184+ fc->sb_flags_mask |= NFS_SB_MASK;
185+ fc->sb_flags &= ~NFS_SB_MASK;
186+ fc->sb_flags |= s_flags & NFS_SB_MASK;
187+
177188 /* for submounts we want the same server; referrals will reassign */
178189 memcpy(&ctx->nfs_server._address, &client->cl_addr, client->cl_addrlen);
179190 ctx->nfs_server.addrlen = client->cl_addrlen;
@@ -184,6 +195,10 @@ struct vfsmount *nfs_d_automount(struct path *path) · 4 unmodified lines
184195 ctx->nfs_mod = client->cl_nfs_mod;
185196 get_nfs_version(ctx->nfs_mod);
186197
198+ /* Inherit block sizes if they were specified as mount parameters */
199+ if (server->automount_inherit & NFS_AUTOMOUNT_INHERIT_BSIZE)
200+ ctx->bsize = server->bsize;
201+
187202 ret = client->rpc_ops->submount(fc, server);
188203 if (ret < 0) {
189204 mnt = ERR_PTR(ret);
@@ -283,7 +298,6 @@ int nfs_do_submount(struct fs_context *fc) · 93 unmodified lines
283298 return -ENOMEM;
284299
285300 ctx->internal = true;
286− ctx->clone_data.inherited_bsize = ctx->clone_data.sb->s_blocksize_bits;
287301
288302 p = nfs_devname(dentry, buffer, 4096);
289303 if (IS_ERR(p)) {
fs/nfs/nfs3proc.c+2−1
@@ -483,7 +483,8 @@ nfs3_proc_unlink_done(struct rpc_task *task, struct inode *dir) · 482 unmodified lines
483483 static void
484484 nfs3_proc_rename_setup(struct rpc_message *msg,
485485 struct dentry *old_dentry,
486− struct dentry *new_dentry)
486+ struct dentry *new_dentry,
487+ struct inode *same_parent)
487488 {
488489 msg->rpc_proc = &nfs3_procedures[NFS3PROC_RENAME];
489490 }
fs/nfs/nfs4client.c+21−6
@@ -281,8 +281,13 @@ error: · 280 unmodified lines
281281 */
282282 static void nfs4_destroy_callback(struct nfs_client *clp)
283283 {
284− if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
285− nfs_callback_down(clp->cl_mvops->minor_version, clp->cl_net);
284+ if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state)) {
285+ struct rpc_xprt *xprt;
286+
287+ xprt = rcu_dereference_raw(clp->cl_rpcclient->cl_xprt);
288+ nfs_callback_down(clp->cl_mvops->minor_version, clp->cl_net,
289+ xprt);
290+ }
286291 }
287292
288293 static void nfs4_shutdown_client(struct nfs_client *clp)
@@ -1174,10 +1179,20 @@ static int nfs4_init_server(struct nfs_server *server, struct fs_context *fc) · 885 unmodified lines
11741179 if (error < 0)
11751180 return error;
11761181
1177− if (ctx->rsize)
1178− server->rsize = nfs_io_size(ctx->rsize, server->nfs_client->cl_proto);
1179− if (ctx->wsize)
1180− server->wsize = nfs_io_size(ctx->wsize, server->nfs_client->cl_proto);
1182+ if (ctx->bsize) {
1183+ server->bsize = ctx->bsize;
1184+ server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_BSIZE;
1185+ }
1186+ if (ctx->rsize) {
1187+ server->rsize =
1188+ nfs_io_size(ctx->rsize, server->nfs_client->cl_proto);
1189+ server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_RSIZE;
1190+ }
1191+ if (ctx->wsize) {
1192+ server->wsize =
1193+ nfs_io_size(ctx->wsize, server->nfs_client->cl_proto);
1194+ server->automount_inherit |= NFS_AUTOMOUNT_INHERIT_WSIZE;
1195+ }
11811196
11821197 server->acregmin = ctx->acregmin * HZ;
11831198 server->acregmax = ctx->acregmax * HZ;
fs/nfs/nfs4proc.c+91−20
@@ -1780,8 +1780,17 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state, · 1779 unmodified lines
17801780 if (nfs_stateid_is_sequential(state, stateid))
17811781 break;
17821782
1783− if (status)
1784− break;
1783+ if (status) {
1784+ if (nfs4_stateid_match_other(stateid, &state->open_stateid) &&
1785+ !nfs4_stateid_is_newer(stateid, &state->open_stateid)) {
1786+ trace_nfs4_open_stateid_update_skip(state->inode,
1787+ stateid, status);
1788+ return;
1789+ } else {
1790+ break;
1791+ }
1792+ }
1793+
17851794 /* Rely on seqids for serialisation with NFSv4.0 */
17861795 if (!nfs4_has_session(NFS_SERVER(state->inode)->nfs_client))
17871796 break;
@@ -3174,18 +3183,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, · 1386 unmodified lines
31743183 if (opendata->o_res.rflags & NFS4_OPEN_RESULT_PRESERVE_UNLINKED)
31753184 set_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(state->inode)->flags);
31763185
3177− dentry = opendata->dentry;
3178− if (d_really_is_negative(dentry)) {
3179− struct dentry *alias;
3180− d_drop(dentry);
3181− alias = d_splice_alias(igrab(state->inode), dentry);
3182− /* d_splice_alias() can't fail here - it's a non-directory */
3183− if (alias) {
3184− dput(ctx->dentry);
3185− ctx->dentry = dentry = alias;
3186− }
3187− }
3188−
31893186 switch(opendata->o_arg.claim) {
31903187 default:
31913188 break;
@@ -3196,7 +3193,20 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, · 4 unmodified lines
31963193 break;
31973194 if (opendata->o_res.delegation.type != 0)
31983195 dir_verifier = nfs_save_change_attribute(dir);
3199− nfs_set_verifier(dentry, dir_verifier);
3196+ }
3197+
3198+ dentry = opendata->dentry;
3199+ nfs_set_verifier(dentry, dir_verifier);
3200+ if (d_really_is_negative(dentry)) {
3201+ struct dentry *alias;
3202+ d_drop(dentry);
3203+ alias = d_splice_alias(igrab(state->inode), dentry);
3204+ /* d_splice_alias() can't fail here - it's a non-directory */
3205+ if (alias) {
3206+ dput(ctx->dentry);
3207+ nfs_set_verifier(alias, dir_verifier);
3208+ ctx->dentry = dentry = alias;
3209+ }
32003210 }
32013211
32023212 /* Parse layoutget results before we check for access */
@@ -4460,6 +4470,30 @@ out: · 1257 unmodified lines
44604470 return status;
44614471 }
44624472
4473+#if IS_ENABLED(CONFIG_NFS_V4_1)
4474+static bool should_request_dir_deleg(struct inode *inode)
4475+{
4476+ if (!directory_delegations)
4477+ return false;
4478+ if (!inode)
4479+ return false;
4480+ if (!S_ISDIR(inode->i_mode))
4481+ return false;
4482+ if (!nfs_server_capable(inode, NFS_CAP_DIR_DELEG))
4483+ return false;
4484+ if (!test_and_clear_bit(NFS_INO_REQ_DIR_DELEG, &(NFS_I(inode)->flags)))
4485+ return false;
4486+ if (nfs4_have_delegation(inode, FMODE_READ, 0))
4487+ return false;
4488+ return true;
4489+}
4490+#else
4491+static bool should_request_dir_deleg(struct inode *inode)
4492+{
4493+ return false;
4494+}
4495+#endif /* CONFIG_NFS_V4_1 */
4496+
44634497 static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
44644498 struct nfs_fattr *fattr, struct inode *inode)
44654499 {
@@ -4477,7 +4511,9 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, · 11 unmodified lines
44774511 .rpc_argp = &args,
44784512 .rpc_resp = &res,
44794513 };
4514+ struct nfs4_gdd_res gdd_res;
44804515 unsigned short task_flags = 0;
4516+ int status;
44814517
44824518 if (nfs4_has_session(server->nfs_client))
44834519 task_flags = RPC_TASK_MOVEABLE;
@@ -4486,11 +4522,31 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, · 2 unmodified lines
44864522 if (inode && (server->flags & NFS_MOUNT_SOFTREVAL))
44874523 task_flags |= RPC_TASK_TIMEOUT;
44884524
4525+ args.get_dir_deleg = should_request_dir_deleg(inode);
4526+ if (args.get_dir_deleg)
4527+ res.gdd_res = &gdd_res;
4528+
44894529 nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, fattr->label), inode, 0);
44904530 nfs_fattr_init(fattr);
44914531 nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 0);
4492− return nfs4_do_call_sync(server->client, server, &msg,
4493− &args.seq_args, &res.seq_res, task_flags);
4532+
4533+ status = nfs4_do_call_sync(server->client, server, &msg,
4534+ &args.seq_args, &res.seq_res, task_flags);
4535+ if (args.get_dir_deleg) {
4536+ switch (status) {
4537+ case 0:
4538+ if (gdd_res.status != GDD4_OK)
4539+ break;
4540+ status = nfs_inode_set_delegation(
4541+ inode, current_cred(), FMODE_READ,
4542+ &gdd_res.deleg, 0, NFS4_OPEN_DELEGATE_READ);
4543+ break;
4544+ case -ENOTSUPP:
4545+ case -EOPNOTSUPP:
4546+ server->caps &= ~NFS_CAP_DIR_DELEG;
4547+ }
4548+ }
4549+ return status;
44944550 }
44954551
44964552 int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
@@ -4503,8 +4559,14 @@ int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, · 6 unmodified lines
45034559 do {
45044560 err = _nfs4_proc_getattr(server, fhandle, fattr, inode);
45054561 trace_nfs4_getattr(server, fhandle, fattr, err);
4506− err = nfs4_handle_exception(server, err,
4507− &exception);
4562+ switch (err) {
4563+ default:
4564+ err = nfs4_handle_exception(server, err, &exception);
4565+ break;
4566+ case -ENOTSUPP:
4567+ case -EOPNOTSUPP:
4568+ exception.retry = true;
4569+ }
45084570 } while (exception.retry);
45094571 return err;
45104572 }
@@ -4768,6 +4830,7 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry · 257 unmodified lines
47684830 int status = 0;
47694831
47704832 if (!nfs4_have_delegation(inode, FMODE_READ, 0)) {
4833+ nfs_request_directory_delegation(inode);
47714834 res.fattr = nfs_alloc_fattr();
47724835 if (res.fattr == NULL)
47734836 return -ENOMEM;
@@ -4875,6 +4938,8 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, · 101 unmodified lines
48754938
48764939 ilabel = nfs4_label_init_security(dir, dentry, sattr, &l);
48774940
4941+ nfs_request_directory_delegation(dir);
4942+
48784943 if (!(server->attr_bitmask[2] & FATTR4_WORD2_MODE_UMASK))
48794944 sattr->ia_mode &= ~current_umask();
48804945 state = nfs4_do_open(dir, ctx, flags, sattr, ilabel, NULL);
@@ -4971,6 +5036,7 @@ static void nfs4_proc_unlink_setup(struct rpc_message *msg, · 90 unmodified lines
49715036 nfs4_init_sequence(&args->seq_args, &res->seq_res, 1, 0);
49725037
49735038 nfs_fattr_init(res->dir_attr);
5039+ nfs_request_directory_delegation(d_inode(dentry->d_parent));
49745040
49755041 if (inode) {
49765042 nfs4_inode_return_delegation(inode);
@@ -5005,7 +5071,8 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir) · 28 unmodified lines
50055071
50065072 static void nfs4_proc_rename_setup(struct rpc_message *msg,
50075073 struct dentry *old_dentry,
5008− struct dentry *new_dentry)
5074+ struct dentry *new_dentry,
5075+ struct inode *same_parent)
50095076 {
50105077 struct nfs_renameargs *arg = msg->rpc_argp;
50115078 struct nfs_renameres *res = msg->rpc_resp;
@@ -5016,6 +5083,8 @@ static void nfs4_proc_rename_setup(struct rpc_message *msg, · 4 unmodified lines
50165083 nfs4_inode_make_writeable(old_inode);
50175084 if (new_inode)
50185085 nfs4_inode_return_delegation(new_inode);
5086+ if (same_parent)
5087+ nfs_request_directory_delegation(same_parent);
50195088 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME];
50205089 res->server = NFS_SB(old_dentry->d_sb);
50215090 nfs4_init_sequence(&arg->seq_args, &res->seq_res, 1, 0);
@@ -10822,6 +10891,7 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = { · 5800 unmodified lines
1082210891 .minor_version = 1,
1082310892 .init_caps = NFS_CAP_READDIRPLUS
1082410893 | NFS_CAP_ATOMIC_OPEN
10894+ | NFS_CAP_DIR_DELEG
1082510895 | NFS_CAP_POSIX_LOCK
1082610896 | NFS_CAP_STATEID_NFSV41
1082710897 | NFS_CAP_ATOMIC_OPEN_V1
@@ -10848,6 +10918,7 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { · 20 unmodified lines
1084810918 .minor_version = 2,
1084910919 .init_caps = NFS_CAP_READDIRPLUS
1085010920 | NFS_CAP_ATOMIC_OPEN
10921+ | NFS_CAP_DIR_DELEG
1085110922 | NFS_CAP_POSIX_LOCK
1085210923 | NFS_CAP_STATEID_NFSV41
1085310924 | NFS_CAP_ATOMIC_OPEN_V1
fs/nfs/nfs4trace.h+1−0
@@ -1353,6 +1353,7 @@ DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_setattr); · 1352 unmodified lines
13531353 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_delegreturn);
13541354 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update);
13551355 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update_wait);
1356+DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_open_stateid_update_skip);
13561357 DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_close_stateid_update_wait);
13571358
13581359 DECLARE_EVENT_CLASS(nfs4_getattr_event,
fs/nfs/nfs4xdr.c+106−0
@@ -393,6 +393,20 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, · 392 unmodified lines
393393 XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5)
394394 #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4)
395395 #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4)
396+#define encode_get_dir_deleg_maxsz (op_encode_hdr_maxsz + \
397+ 4 /* gdda_signal_deleg_avail */ + \
398+ 8 /* gdda_notification_types */ + \
399+ nfstime4_maxsz /* gdda_child_attr_delay */ + \
400+ nfstime4_maxsz /* gdda_dir_attr_delay */ + \
401+ nfs4_fattr_bitmap_maxsz /* gdda_child_attributes */ + \
402+ nfs4_fattr_bitmap_maxsz /* gdda_dir_attributes */)
403+#define decode_get_dir_deleg_maxsz (op_decode_hdr_maxsz + \
404+ 4 /* gddrnf_status */ + \
405+ encode_verifier_maxsz /* gddr_cookieverf */ + \
406+ encode_stateid_maxsz /* gddr_stateid */ + \
407+ 8 /* gddr_notification */ + \
408+ nfs4_fattr_maxsz /* gddr_child_attributes */ + \
409+ nfs4_fattr_maxsz /* gddr_dir_attributes */)
396410 #define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + \
397411 XDR_QUADLEN(NFS4_DEVICEID4_SIZE) + \
398412 1 /* layout type */ + \
@@ -444,6 +458,8 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, · 45 unmodified lines
444458 #else /* CONFIG_NFS_V4_1 */
445459 #define encode_sequence_maxsz 0
446460 #define decode_sequence_maxsz 0
461+#define encode_get_dir_deleg_maxsz 0
462+#define decode_get_dir_deleg_maxsz 0
447463 #define encode_layoutreturn_maxsz 0
448464 #define decode_layoutreturn_maxsz 0
449465 #define encode_layoutget_maxsz 0
@@ -631,11 +647,13 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req, · 181 unmodified lines
631647 #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \
632648 encode_sequence_maxsz + \
633649 encode_putfh_maxsz + \
650+ encode_get_dir_deleg_maxsz + \
634651 encode_getattr_maxsz + \
635652 encode_renew_maxsz)
636653 #define NFS4_dec_getattr_sz (compound_decode_hdr_maxsz + \
637654 decode_sequence_maxsz + \
638655 decode_putfh_maxsz + \
656+ decode_get_dir_deleg_maxsz + \
639657 decode_getattr_maxsz + \
640658 decode_renew_maxsz)
641659 #define NFS4_enc_lookup_sz (compound_encode_hdr_maxsz + \
@@ -2007,6 +2025,33 @@ static void encode_sequence(struct xdr_stream *xdr, · 1365 unmodified lines
20072025 }
20082026
20092027 #ifdef CONFIG_NFS_V4_1
2028+static void
2029+encode_get_dir_delegation(struct xdr_stream *xdr, struct compound_hdr *hdr)
2030+{
2031+ struct timespec64 ts = { 0, 0 };
2032+ u32 notifications[1] = { 0 };
2033+ u32 attributes[1] = { 0 };
2034+ __be32 *p;
2035+
2036+ encode_op_hdr(xdr, OP_GET_DIR_DELEGATION, decode_get_dir_deleg_maxsz, hdr);
2037+
2038+ /* We don't handle CB_RECALLABLE_OBJ_AVAIL yet. */
2039+ xdr_stream_encode_bool(xdr, false);
2040+
2041+ xdr_encode_bitmap4(xdr, notifications, ARRAY_SIZE(notifications));
2042+
2043+ /* Request no delay on attribute updates */
2044+ p = reserve_space(xdr, 12 + 12);
2045+ p = xdr_encode_nfstime4(p, &ts);
2046+ xdr_encode_nfstime4(p, &ts);
2047+
2048+ /* Requested child attributes */
2049+ xdr_encode_bitmap4(xdr, attributes, ARRAY_SIZE(attributes));
2050+
2051+ /* Requested dir attributes */
2052+ xdr_encode_bitmap4(xdr, attributes, ARRAY_SIZE(attributes));
2053+}
2054+
20102055 static void
20112056 encode_getdeviceinfo(struct xdr_stream *xdr,
20122057 const struct nfs4_getdeviceinfo_args *args,
@@ -2142,6 +2187,11 @@ static void encode_free_stateid(struct xdr_stream *xdr, · 129 unmodified lines
21422187 encode_nfs4_stateid(xdr, &args->stateid);
21432188 }
21442189 #else
2190+static inline void
2191+encode_get_dir_delegation(struct xdr_stream *xdr, struct compound_hdr *hdr)
2192+{
2193+}
2194+
21452195 static inline void
21462196 encode_layoutreturn(struct xdr_stream *xdr,
21472197 const struct nfs4_layoutreturn_args *args,
@@ -2356,6 +2406,8 @@ static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr, · 208 unmodified lines
23562406 encode_compound_hdr(xdr, req, &hdr);
23572407 encode_sequence(xdr, &args->seq_args, &hdr);
23582408 encode_putfh(xdr, args->fh, &hdr);
2409+ if (args->get_dir_deleg)
2410+ encode_get_dir_delegation(xdr, &hdr);
23592411 encode_getfattr(xdr, args->bitmask, &hdr);
23602412 encode_nops(&hdr);
23612413 }
@@ -5994,6 +6046,49 @@ static int decode_layout_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) · 3632 unmodified lines
59946046 return decode_stateid(xdr, stateid);
59956047 }
59966048
6049+static int decode_get_dir_delegation(struct xdr_stream *xdr,
6050+ struct nfs4_getattr_res *res)
6051+{
6052+ struct nfs4_gdd_res *gdd_res = res->gdd_res;
6053+ nfs4_verifier cookieverf;
6054+ u32 bitmap[1];
6055+ int status;
6056+
6057+ status = decode_op_hdr(xdr, OP_GET_DIR_DELEGATION);
6058+ if (status)
6059+ return status;
6060+
6061+ if (xdr_stream_decode_u32(xdr, &gdd_res->status))
6062+ return -EIO;
6063+
6064+ if (gdd_res->status == GDD4_UNAVAIL)
6065+ return xdr_inline_decode(xdr, 4) ? 0 : -EIO;
6066+
6067+ status = decode_verifier(xdr, &cookieverf);
6068+ if (status)
6069+ return status;
6070+
6071+ status = decode_delegation_stateid(xdr, &gdd_res->deleg);
6072+ if (status)
6073+ return status;
6074+
6075+ /* Decode supported notification types. */
6076+ status = decode_bitmap4(xdr, bitmap, ARRAY_SIZE(bitmap));
6077+ if (status < 0)
6078+ return status;
6079+
6080+ /* Decode supported child attributes. */
6081+ status = decode_bitmap4(xdr, bitmap, ARRAY_SIZE(bitmap));
6082+ if (status < 0)
6083+ return status;
6084+
6085+ /* Decode supported attributes. */
6086+ status = decode_bitmap4(xdr, bitmap, ARRAY_SIZE(bitmap));
6087+ if (status < 0)
6088+ return status;
6089+ return 0;
6090+}
6091+
59976092 static int decode_getdeviceinfo(struct xdr_stream *xdr,
59986093 struct nfs4_getdeviceinfo_res *res)
59996094 {
@@ -6208,6 +6303,12 @@ static int decode_free_stateid(struct xdr_stream *xdr, · 208 unmodified lines
62086303 return res->status;
62096304 }
62106305 #else
6306+static int decode_get_dir_delegation(struct xdr_stream *xdr,
6307+ struct nfs4_getattr_res *res)
6308+{
6309+ return 0;
6310+}
6311+
62116312 static inline
62126313 int decode_layoutreturn(struct xdr_stream *xdr,
62136314 struct nfs4_layoutreturn_res *res)
@@ -6525,6 +6626,11 @@ static int nfs4_xdr_dec_getattr(struct rpc_rqst *rqstp, struct xdr_stream *xdr, · 311 unmodified lines
65256626 status = decode_putfh(xdr);
65266627 if (status)
65276628 goto out;
6629+ if (res->gdd_res) {
6630+ status = decode_get_dir_delegation(xdr, res);
6631+ if (status)
6632+ goto out;
6633+ }
65286634 status = decode_getfattr(xdr, res->fattr, res->server);
65296635 out:
65306636 return status;
fs/nfs/pnfs.c+1−0
@@ -464,6 +464,7 @@ pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo, · 463 unmodified lines
464464 struct pnfs_layout_segment *lseg, *next;
465465
466466 set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags);
467+ clear_bit(NFS_INO_LAYOUTCOMMIT, &NFS_I(lo->plh_inode)->flags);
467468 list_for_each_entry_safe(lseg, next, &lo->plh_segs, pls_list)
468469 pnfs_clear_lseg_state(lseg, lseg_list);
469470 pnfs_clear_layoutreturn_info(lo);
fs/nfs/proc.c+2−1
@@ -353,7 +353,8 @@ static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir) · 352 unmodified lines
353353 static void
354354 nfs_proc_rename_setup(struct rpc_message *msg,
355355 struct dentry *old_dentry,
356− struct dentry *new_dentry)
356+ struct dentry *new_dentry,
357+ struct inode *same_parent)
357358 {
358359 msg->rpc_proc = &nfs_procedures[NFSPROC_RENAME];
359360 }
fs/nfs/super.c+3−30
@@ -1051,16 +1051,6 @@ int nfs_reconfigure(struct fs_context *fc) · 1050 unmodified lines
10511051
10521052 sync_filesystem(sb);
10531053
1054− /*
1055− * The SB_RDONLY flag has been removed from the superblock during
1056− * mounts to prevent interference between different filesystems.
1057− * Similarly, it is also necessary to ignore the SB_RDONLY flag
1058− * during reconfiguration; otherwise, it may also result in the
1059− * creation of redundant superblocks when mounting a directory with
1060− * different rw and ro flags multiple times.
1061− */
1062− fc->sb_flags_mask &= ~SB_RDONLY;
1063−
10641054 /*
10651055 * Userspace mount programs that send binary options generally send
10661056 * them populated with default values. We have no way to know which
@@ -1101,8 +1091,9 @@ static void nfs_fill_super(struct super_block *sb, struct nfs_fs_context *ctx) · 34 unmodified lines
11011091 sb->s_blocksize = 0;
11021092 sb->s_xattr = server->nfs_client->cl_nfs_mod->xattr;
11031093 sb->s_op = server->nfs_client->cl_nfs_mod->sops;
1104− if (ctx->bsize)
1105− sb->s_blocksize = nfs_block_size(ctx->bsize, &sb->s_blocksize_bits);
1094+ if (server->bsize)
1095+ sb->s_blocksize =
1096+ nfs_block_size(server->bsize, &sb->s_blocksize_bits);
11061097
11071098 switch (server->nfs_client->rpc_ops->version) {
11081099 case 2:
@@ -1318,26 +1309,13 @@ int nfs_get_tree_common(struct fs_context *fc) · 209 unmodified lines
13181309 if (IS_ERR(server))
13191310 return PTR_ERR(server);
13201311
1321− /*
1322− * When NFS_MOUNT_UNSHARED is not set, NFS forces the sharing of a
1323− * superblock among each filesystem that mounts sub-directories
1324− * belonging to a single exported root path.
1325− * To prevent interference between different filesystems, the
1326− * SB_RDONLY flag should be removed from the superblock.
1327− */
13281312 if (server->flags & NFS_MOUNT_UNSHARED)
13291313 compare_super = NULL;
1330− else
1331− fc->sb_flags &= ~SB_RDONLY;
13321314
13331315 /* -o noac implies -o sync */
13341316 if (server->flags & NFS_MOUNT_NOAC)
13351317 fc->sb_flags |= SB_SYNCHRONOUS;
13361318
1337− if (ctx->clone_data.sb)
1338− if (ctx->clone_data.sb->s_flags & SB_SYNCHRONOUS)
1339− fc->sb_flags |= SB_SYNCHRONOUS;
1340−
13411319 /* Get a superblock - note that we may end up sharing one that already exists */
13421320 fc->s_fs_info = server;
13431321 s = sget_fc(fc, compare_super, nfs_set_super);
@@ -1361,13 +1339,8 @@ int nfs_get_tree_common(struct fs_context *fc) · 17 unmodified lines
13611339 }
13621340
13631341 if (!s->s_root) {
1364− unsigned bsize = ctx->clone_data.inherited_bsize;
13651342 /* initial superblock/root creation */
13661343 nfs_fill_super(s, ctx);
1367− if (bsize) {
1368− s->s_blocksize_bits = bsize;
1369− s->s_blocksize = 1U << bsize;
1370− }
13711344 error = nfs_get_cache_cookie(s, ctx);
13721345 if (error < 0)
13731346 goto error_splat_super;
fs/nfs/unlink.c+2−1
@@ -390,7 +390,8 @@ nfs_async_rename(struct inode *old_dir, struct inode *new_dir, · 389 unmodified lines
390390
391391 nfs_sb_active(old_dir->i_sb);
392392
393− NFS_PROTO(data->old_dir)->rename_setup(&msg, old_dentry, new_dentry);
393+ NFS_PROTO(data->old_dir)->rename_setup(&msg, old_dentry, new_dentry,
394+ old_dir == new_dir ? old_dir : NULL);
394395
395396 return rpc_run_task(&task_setup_data);
396397 }
include/linux/nfs_fs.h+1−0
@@ -344,6 +344,7 @@ struct nfs4_copy_state { · 343 unmodified lines
344344 #define NFS_INO_LAYOUTCOMMITTING (10) /* layoutcommit inflight */
345345 #define NFS_INO_LAYOUTSTATS (11) /* layoutstats inflight */
346346 #define NFS_INO_ODIRECT (12) /* I/O setting is O_DIRECT */
347+#define NFS_INO_REQ_DIR_DELEG (13) /* Request a directory delegation */
347348
348349 static inline struct nfs_inode *NFS_I(const struct inode *inode)
349350 {
include/linux/nfs_fs_sb.h+6−0
@@ -172,6 +172,11 @@ struct nfs_server { · 171 unmodified lines
172172 #define NFS_MOUNT_FORCE_RDIRPLUS 0x20000000
173173 #define NFS_MOUNT_NETUNREACH_FATAL 0x40000000
174174
175+ unsigned int automount_inherit; /* Properties inherited by automount */
176+#define NFS_AUTOMOUNT_INHERIT_BSIZE 0x0001
177+#define NFS_AUTOMOUNT_INHERIT_RSIZE 0x0002
178+#define NFS_AUTOMOUNT_INHERIT_WSIZE 0x0004
179+
175180 unsigned int caps; /* server capabilities */
176181 __u64 fattr_valid; /* Valid attributes */
177182 unsigned int rsize; /* read size */
@@ -305,6 +310,7 @@ struct nfs_server { · 127 unmodified lines
305310 #define NFS_CAP_REBOOT_LAYOUTRETURN (1U << 8)
306311 #define NFS_CAP_OFFLOAD_STATUS (1U << 9)
307312 #define NFS_CAP_ZERO_RANGE (1U << 10)
313+#define NFS_CAP_DIR_DELEG (1U << 11)
308314 #define NFS_CAP_OPEN_XOR (1U << 12)
309315 #define NFS_CAP_DELEGTIME (1U << 13)
310316 #define NFS_CAP_POSIX_LOCK (1U << 14)
include/linux/nfs_xdr.h+9−1
@@ -1092,12 +1092,19 @@ struct nfs4_getattr_arg { · 1091 unmodified lines
10921092 struct nfs4_sequence_args seq_args;
10931093 const struct nfs_fh * fh;
10941094 const u32 * bitmask;
1095+ bool get_dir_deleg;
1096+};
1097+
1098+struct nfs4_gdd_res {
1099+ u32 status;
1100+ nfs4_stateid deleg;
10951101 };
10961102
10971103 struct nfs4_getattr_res {
10981104 struct nfs4_sequence_res seq_res;
10991105 const struct nfs_server * server;
11001106 struct nfs_fattr * fattr;
1107+ struct nfs4_gdd_res * gdd_res;
11011108 };
11021109
11031110 struct nfs4_link_arg {
@@ -1801,7 +1808,8 @@ struct nfs_rpc_ops { · 697 unmodified lines
18011808 int (*unlink_done) (struct rpc_task *, struct inode *);
18021809 void (*rename_setup) (struct rpc_message *msg,
18031810 struct dentry *old_dentry,
1804− struct dentry *new_dentry);
1811+ struct dentry *new_dentry,
1812+ struct inode *same_parent);
18051813 void (*rename_rpc_prepare)(struct rpc_task *task, struct nfs_renamedata *);
18061814 int (*rename_done) (struct rpc_task *task, struct inode *old_dir, struct inode *new_dir);
18071815 int (*link) (struct inode *, struct inode *, const struct qstr *);
include/linux/sunrpc/bc_xprt.h+7−0
@@ -25,12 +25,14 @@ void xprt_init_bc_request(struct rpc_rqst *req, struct rpc_task *task, · 24 unmodified lines
2525 void xprt_free_bc_request(struct rpc_rqst *req);
2626 int xprt_setup_backchannel(struct rpc_xprt *, unsigned int min_reqs);
2727 void xprt_destroy_backchannel(struct rpc_xprt *, unsigned int max_reqs);
28+void xprt_enqueue_bc_request(struct rpc_rqst *req);
2829
2930 /* Socket backchannel transport methods */
3031 int xprt_setup_bc(struct rpc_xprt *xprt, unsigned int min_reqs);
3132 void xprt_destroy_bc(struct rpc_xprt *xprt, unsigned int max_reqs);
3233 void xprt_free_bc_rqst(struct rpc_rqst *req);
3334 unsigned int xprt_bc_max_slots(struct rpc_xprt *xprt);
35+void xprt_svc_destroy_nullify_bc(struct rpc_xprt *xprt, struct svc_serv **serv);
3436
3537 /*
3638 * Determine if a shared backchannel is in use
@@ -68,5 +70,10 @@ static inline void set_bc_enabled(struct svc_serv *serv) · 31 unmodified lines
6870 static inline void xprt_free_bc_request(struct rpc_rqst *req)
6971 {
7072 }
73+
74+static inline void xprt_svc_destroy_nullify_bc(struct rpc_xprt *xprt, struct svc_serv **serv)
75+{
76+ svc_destroy(serv);
77+}
7178 #endif /* CONFIG_SUNRPC_BACKCHANNEL */
7279 #endif /* _LINUX_SUNRPC_BC_XPRT_H */
net/sunrpc/backchannel_rqst.c+32−3
@@ -24,6 +24,22 @@ unsigned int xprt_bc_max_slots(struct rpc_xprt *xprt) · 23 unmodified lines
2424 return BC_MAX_SLOTS;
2525 }
2626
27+/*
28+ * Helper function to nullify backchannel server pointer in transport.
29+ * We need to synchronize setting the pointer to NULL (done so after
30+ * the backchannel server is shutdown) with the usage of that pointer
31+ * by the backchannel request processing routines
32+ * xprt_complete_bc_request() and rpcrdma_bc_receive_call().
33+ */
34+void xprt_svc_destroy_nullify_bc(struct rpc_xprt *xprt, struct svc_serv **serv)
35+{
36+ spin_lock(&xprt->bc_pa_lock);
37+ svc_destroy(serv);
38+ xprt->bc_serv = NULL;
39+ spin_unlock(&xprt->bc_pa_lock);
40+}
41+EXPORT_SYMBOL_GPL(xprt_svc_destroy_nullify_bc);
42+
2743 /*
2844 * Helper routines that track the number of preallocation elements
2945 * on the transport.
@@ -354,7 +370,6 @@ found: · 324 unmodified lines
354370 void xprt_complete_bc_request(struct rpc_rqst *req, uint32_t copied)
355371 {
356372 struct rpc_xprt *xprt = req->rq_xprt;
357− struct svc_serv *bc_serv = xprt->bc_serv;
358373
359374 spin_lock(&xprt->bc_pa_lock);
360375 list_del(&req->rq_bc_pa_list);
@@ -365,7 +380,21 @@ void xprt_complete_bc_request(struct rpc_rqst *req, uint32_t copied) · 4 unmodified lines
365380 set_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state);
366381
367382 dprintk("RPC: add callback request to list\n");
383+ xprt_enqueue_bc_request(req);
384+}
385+
386+void xprt_enqueue_bc_request(struct rpc_rqst *req)
387+{
388+ struct rpc_xprt *xprt = req->rq_xprt;
389+ struct svc_serv *bc_serv;
390+
368391 xprt_get(xprt);
369− lwq_enqueue(&req->rq_bc_list, &bc_serv->sv_cb_list);
370− svc_pool_wake_idle_thread(&bc_serv->sv_pools[0]);
392+ spin_lock(&xprt->bc_pa_lock);
393+ bc_serv = xprt->bc_serv;
394+ if (bc_serv) {
395+ lwq_enqueue(&req->rq_bc_list, &bc_serv->sv_cb_list);
396+ svc_pool_wake_idle_thread(&bc_serv->sv_pools[0]);
397+ }
398+ spin_unlock(&xprt->bc_pa_lock);
371399 }
400+EXPORT_SYMBOL_GPL(xprt_enqueue_bc_request);
net/sunrpc/xprtrdma/backchannel.c+2−6
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 #include <linux/sunrpc/svc.h>
1010 #include <linux/sunrpc/svc_xprt.h>
1111 #include <linux/sunrpc/svc_rdma.h>
12+#include <linux/sunrpc/bc_xprt.h>
1213
1314 #include "xprt_rdma.h"
1415 #include <trace/events/rpcrdma.h>
@@ -220,7 +221,6 @@ void rpcrdma_bc_receive_call(struct rpcrdma_xprt *r_xprt, · 205 unmodified lines
220221 struct rpcrdma_rep *rep)
221222 {
222223 struct rpc_xprt *xprt = &r_xprt->rx_xprt;
223− struct svc_serv *bc_serv;
224224 struct rpcrdma_req *req;
225225 struct rpc_rqst *rqst;
226226 struct xdr_buf *buf;
@@ -261,11 +261,7 @@ void rpcrdma_bc_receive_call(struct rpcrdma_xprt *r_xprt, · 34 unmodified lines
261261 trace_xprtrdma_cb_call(r_xprt, rqst);
262262
263263 /* Queue rqst for ULP's callback service */
264− bc_serv = xprt->bc_serv;
265− xprt_get(xprt);
266− lwq_enqueue(&rqst->rq_bc_list, &bc_serv->sv_cb_list);
267−
268− svc_pool_wake_idle_thread(&bc_serv->sv_pools[0]);
264+ xprt_enqueue_bc_request(rqst);
269265
270266 r_xprt->rx_stats.bcall_count++;
271267 return;