Skip to content

Commit 04de788

Browse files
committed
Merge tag 'nfs-for-5.7-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client updates from Trond Myklebust: "Highlights include: Stable fixes: - Fix a page leak in nfs_destroy_unlinked_subrequests() - Fix use-after-free issues in nfs_pageio_add_request() - Fix new mount code constant_table array definitions - finish_automount() requires us to hold 2 refs to the mount record Features: - Improve the accuracy of telldir/seekdir by using 64-bit cookies when possible. - Allow one RDMA active connection and several zombie connections to prevent blocking if the remote server is unresponsive. - Limit the size of the NFS access cache by default - Reduce the number of references to credentials that are taken by NFS - pNFS files and flexfiles drivers now support per-layout segment COMMIT lists. - Enable partial-file layout segments in the pNFS/flexfiles driver. - Add support for CB_RECALL_ANY to the pNFS flexfiles layout type - pNFS/flexfiles Report NFS4ERR_DELAY and NFS4ERR_GRACE errors from the DS using the layouterror mechanism. Bugfixes and cleanups: - SUNRPC: Fix krb5p regressions - Don't specify NFS version in "UDP not supported" error - nfsroot: set tcp as the default transport protocol - pnfs: Return valid stateids in nfs_layout_find_inode_by_stateid() - alloc_nfs_open_context() must use the file cred when available - Fix locking when dereferencing the delegation cred - Fix memory leaks in O_DIRECT when nfs_get_lock_context() fails - Various clean ups of the NFS O_DIRECT commit code - Clean up RDMA connect/disconnect - Replace zero-length arrays with C99-style flexible arrays" * tag 'nfs-for-5.7-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (86 commits) NFS: Clean up process of marking inode stale. SUNRPC: Don't start a timer on an already queued rpc task NFS/pnfs: Reference the layout cred in pnfs_prepare_layoutreturn() NFS/pnfs: Fix dereference of layout cred in pnfs_layoutcommit_inode() NFS: Beware when dereferencing the delegation cred NFS: Add a module parameter to set nfs_mountpoint_expiry_timeout NFS: finish_automount() requires us to hold 2 refs to the mount record NFS: Fix a few constant_table array definitions NFS: Try to join page groups before an O_DIRECT retransmission NFS: Refactor nfs_lock_and_join_requests() NFS: Reverse the submission order of requests in __nfs_pageio_add_request() NFS: Clean up nfs_lock_and_join_requests() NFS: Remove the redundant function nfs_pgio_has_mirroring() NFS: Fix memory leaks in nfs_pageio_stop_mirroring() NFS: Fix a request reference leak in nfs_direct_write_clear_reqs() NFS: Fix use-after-free issues in nfs_pageio_add_request() NFS: Fix races nfs_page_group_destroy() vs nfs_destroy_unlinked_subrequests() NFS: Fix a page leak in nfs_destroy_unlinked_subrequests() NFS: Remove unused FLUSH_SYNC support in nfs_initiate_pgio() pNFS/flexfiles: Specify the layout segment range in LAYOUTGET ...
2 parents f40f31c + 93ce4af commit 04de788

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2305
-1958
lines changed

fs/nfs/blocklayout/blocklayout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static void bl_free_layout_hdr(struct pnfs_layout_hdr *lo)
476476
err = ext_tree_remove(bl, true, 0, LLONG_MAX);
477477
WARN_ON(err);
478478

479-
kfree(bl);
479+
kfree_rcu(bl, bl_layout.plh_rcu);
480480
}
481481

482482
static struct pnfs_layout_hdr *__bl_alloc_layout_hdr(struct inode *inode,

fs/nfs/callback.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ extern __be32 nfs4_callback_sequence(void *argp, void *resp,
127127
#define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX 9
128128
#define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12
129129
#define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15
130-
#define RCA4_TYPE_MASK_ALL 0xf31f
130+
#define PNFS_FF_RCA4_TYPE_MASK_READ 16
131+
#define PNFS_FF_RCA4_TYPE_MASK_RW 17
132+
#define RCA4_TYPE_MASK_ALL 0x3f31f
131133

132134
struct cb_recallanyargs {
133135
uint32_t craa_objs_to_keep;

fs/nfs/callback_proc.c

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -121,31 +121,31 @@ __be32 nfs4_callback_recall(void *argp, void *resp,
121121
*/
122122
static struct inode *nfs_layout_find_inode_by_stateid(struct nfs_client *clp,
123123
const nfs4_stateid *stateid)
124+
__must_hold(RCU)
124125
{
125126
struct nfs_server *server;
126127
struct inode *inode;
127128
struct pnfs_layout_hdr *lo;
128129

130+
rcu_read_lock();
129131
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
130-
list_for_each_entry(lo, &server->layouts, plh_layouts) {
132+
list_for_each_entry_rcu(lo, &server->layouts, plh_layouts) {
133+
if (!pnfs_layout_is_valid(lo))
134+
continue;
131135
if (stateid != NULL &&
132136
!nfs4_stateid_match_other(stateid, &lo->plh_stateid))
133137
continue;
138+
if (!nfs_sb_active(server->super))
139+
continue;
134140
inode = igrab(lo->plh_inode);
135-
if (!inode)
136-
return ERR_PTR(-EAGAIN);
137-
if (!nfs_sb_active(inode->i_sb)) {
138-
rcu_read_unlock();
139-
spin_unlock(&clp->cl_lock);
140-
iput(inode);
141-
spin_lock(&clp->cl_lock);
142-
rcu_read_lock();
143-
return ERR_PTR(-EAGAIN);
144-
}
145-
return inode;
141+
rcu_read_unlock();
142+
if (inode)
143+
return inode;
144+
nfs_sb_deactive(server->super);
145+
return ERR_PTR(-EAGAIN);
146146
}
147147
}
148-
148+
rcu_read_unlock();
149149
return ERR_PTR(-ENOENT);
150150
}
151151

@@ -163,28 +163,25 @@ static struct inode *nfs_layout_find_inode_by_fh(struct nfs_client *clp,
163163
struct inode *inode;
164164
struct pnfs_layout_hdr *lo;
165165

166+
rcu_read_lock();
166167
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
167-
list_for_each_entry(lo, &server->layouts, plh_layouts) {
168+
list_for_each_entry_rcu(lo, &server->layouts, plh_layouts) {
168169
nfsi = NFS_I(lo->plh_inode);
169170
if (nfs_compare_fh(fh, &nfsi->fh))
170171
continue;
171172
if (nfsi->layout != lo)
172173
continue;
174+
if (!nfs_sb_active(server->super))
175+
continue;
173176
inode = igrab(lo->plh_inode);
174-
if (!inode)
175-
return ERR_PTR(-EAGAIN);
176-
if (!nfs_sb_active(inode->i_sb)) {
177-
rcu_read_unlock();
178-
spin_unlock(&clp->cl_lock);
179-
iput(inode);
180-
spin_lock(&clp->cl_lock);
181-
rcu_read_lock();
182-
return ERR_PTR(-EAGAIN);
183-
}
184-
return inode;
177+
rcu_read_unlock();
178+
if (inode)
179+
return inode;
180+
nfs_sb_deactive(server->super);
181+
return ERR_PTR(-EAGAIN);
185182
}
186183
}
187-
184+
rcu_read_unlock();
188185
return ERR_PTR(-ENOENT);
189186
}
190187

@@ -194,14 +191,9 @@ static struct inode *nfs_layout_find_inode(struct nfs_client *clp,
194191
{
195192
struct inode *inode;
196193

197-
spin_lock(&clp->cl_lock);
198-
rcu_read_lock();
199194
inode = nfs_layout_find_inode_by_stateid(clp, stateid);
200195
if (inode == ERR_PTR(-ENOENT))
201196
inode = nfs_layout_find_inode_by_fh(clp, fh);
202-
rcu_read_unlock();
203-
spin_unlock(&clp->cl_lock);
204-
205197
return inode;
206198
}
207199

@@ -280,7 +272,7 @@ static u32 initiate_file_draining(struct nfs_client *clp,
280272
goto unlock;
281273
}
282274

283-
pnfs_set_layout_stateid(lo, &args->cbl_stateid, true);
275+
pnfs_set_layout_stateid(lo, &args->cbl_stateid, NULL, true);
284276
switch (pnfs_mark_matching_lsegs_return(lo, &free_me_list,
285277
&args->cbl_range,
286278
be32_to_cpu(args->cbl_stateid.seqid))) {
@@ -605,6 +597,7 @@ __be32 nfs4_callback_recallany(void *argp, void *resp,
605597
struct cb_recallanyargs *args = argp;
606598
__be32 status;
607599
fmode_t flags = 0;
600+
bool schedule_manager = false;
608601

609602
status = cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION);
610603
if (!cps->clp) /* set in cb_sequence */
@@ -627,6 +620,18 @@ __be32 nfs4_callback_recallany(void *argp, void *resp,
627620

628621
if (args->craa_type_mask & BIT(RCA4_TYPE_MASK_FILE_LAYOUT))
629622
pnfs_recall_all_layouts(cps->clp);
623+
624+
if (args->craa_type_mask & BIT(PNFS_FF_RCA4_TYPE_MASK_READ)) {
625+
set_bit(NFS4CLNT_RECALL_ANY_LAYOUT_READ, &cps->clp->cl_state);
626+
schedule_manager = true;
627+
}
628+
if (args->craa_type_mask & BIT(PNFS_FF_RCA4_TYPE_MASK_RW)) {
629+
set_bit(NFS4CLNT_RECALL_ANY_LAYOUT_RW, &cps->clp->cl_state);
630+
schedule_manager = true;
631+
}
632+
if (schedule_manager)
633+
nfs4_schedule_state_manager(cps->clp);
634+
630635
out:
631636
dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
632637
return status;

0 commit comments

Comments
 (0)