Skip to content

Commit 125f42b

Browse files
committed
Merge tag 'nfs-for-4.12-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client bugfixes from Trond Myklebust: "Bugfixes include: - Fix a typo in commit e092693 ("NFS append COMMIT after synchronous COPY") that breaks copy offload - Fix the connect error propagation in xs_tcp_setup_socket() - Fix a lock leak in nfs40_walk_client_list - Verify that pNFS requests lie within the offset range of the layout segment" * tag 'nfs-for-4.12-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: nfs: Mark unnecessarily extern functions as static SUNRPC: ensure correct error is reported by xs_tcp_setup_socket() NFSv4.0: Fix a lock leak in nfs40_walk_client_list pnfs: Fix the check for requests in range of layout segment xprtrdma: Delete an error message for a failed memory allocation in xprt_rdma_bc_setup() pNFS/flexfiles: missing error code in ff_layout_alloc_lseg() NFS fix COMMIT after COPY
2 parents 3c06e6c + 4f253e1 commit 125f42b

File tree

9 files changed

+40
-19
lines changed

9 files changed

+40
-19
lines changed

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
454454
goto out_err_free;
455455

456456
/* fh */
457+
rc = -EIO;
457458
p = xdr_inline_decode(&stream, 4);
458459
if (!p)
459460
goto out_err_free;

fs/nfs/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ extern struct file_system_type nfs4_referral_fs_type;
398398
bool nfs_auth_info_match(const struct nfs_auth_info *, rpc_authflavor_t);
399399
struct dentry *nfs_try_mount(int, const char *, struct nfs_mount_info *,
400400
struct nfs_subversion *);
401-
void nfs_initialise_sb(struct super_block *);
402401
int nfs_set_sb_security(struct super_block *, struct dentry *, struct nfs_mount_info *);
403402
int nfs_clone_sb_security(struct super_block *, struct dentry *, struct nfs_mount_info *);
404403
struct dentry *nfs_fs_mount_common(struct nfs_server *, int, const char *,
@@ -458,7 +457,6 @@ extern void nfs_read_prepare(struct rpc_task *task, void *calldata);
458457
extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio);
459458

460459
/* super.c */
461-
void nfs_clone_super(struct super_block *, struct nfs_mount_info *);
462460
void nfs_umount_begin(struct super_block *);
463461
int nfs_statfs(struct dentry *, struct kstatfs *);
464462
int nfs_show_options(struct seq_file *, struct dentry *);

fs/nfs/nfs42proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static ssize_t _nfs42_proc_copy(struct file *src,
177177
if (status)
178178
goto out;
179179

180-
if (!nfs_write_verifier_cmp(&res->write_res.verifier.verifier,
180+
if (nfs_write_verifier_cmp(&res->write_res.verifier.verifier,
181181
&res->commit_res.verf->verifier)) {
182182
status = -EAGAIN;
183183
goto out;

fs/nfs/nfs4client.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ int nfs40_walk_client_list(struct nfs_client *new,
582582
*/
583583
nfs4_schedule_path_down_recovery(pos);
584584
default:
585-
spin_lock(&nn->nfs_client_lock);
586585
goto out;
587586
}
588587

fs/nfs/pnfs.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,12 +2094,26 @@ pnfs_generic_pg_check_layout(struct nfs_pageio_descriptor *pgio)
20942094
}
20952095
EXPORT_SYMBOL_GPL(pnfs_generic_pg_check_layout);
20962096

2097+
/*
2098+
* Check for any intersection between the request and the pgio->pg_lseg,
2099+
* and if none, put this pgio->pg_lseg away.
2100+
*/
2101+
static void
2102+
pnfs_generic_pg_check_range(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
2103+
{
2104+
if (pgio->pg_lseg && !pnfs_lseg_request_intersecting(pgio->pg_lseg, req)) {
2105+
pnfs_put_lseg(pgio->pg_lseg);
2106+
pgio->pg_lseg = NULL;
2107+
}
2108+
}
2109+
20972110
void
20982111
pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
20992112
{
21002113
u64 rd_size = req->wb_bytes;
21012114

21022115
pnfs_generic_pg_check_layout(pgio);
2116+
pnfs_generic_pg_check_range(pgio, req);
21032117
if (pgio->pg_lseg == NULL) {
21042118
if (pgio->pg_dreq == NULL)
21052119
rd_size = i_size_read(pgio->pg_inode) - req_offset(req);
@@ -2131,6 +2145,7 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio,
21312145
struct nfs_page *req, u64 wb_size)
21322146
{
21332147
pnfs_generic_pg_check_layout(pgio);
2148+
pnfs_generic_pg_check_range(pgio, req);
21342149
if (pgio->pg_lseg == NULL) {
21352150
pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
21362151
req->wb_context,
@@ -2191,16 +2206,10 @@ pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio,
21912206
seg_end = pnfs_end_offset(pgio->pg_lseg->pls_range.offset,
21922207
pgio->pg_lseg->pls_range.length);
21932208
req_start = req_offset(req);
2194-
WARN_ON_ONCE(req_start >= seg_end);
2209+
21952210
/* start of request is past the last byte of this segment */
2196-
if (req_start >= seg_end) {
2197-
/* reference the new lseg */
2198-
if (pgio->pg_ops->pg_cleanup)
2199-
pgio->pg_ops->pg_cleanup(pgio);
2200-
if (pgio->pg_ops->pg_init)
2201-
pgio->pg_ops->pg_init(pgio, req);
2211+
if (req_start >= seg_end)
22022212
return 0;
2203-
}
22042213

22052214
/* adjust 'size' iff there are fewer bytes left in the
22062215
* segment than what nfs_generic_pg_test returned */

fs/nfs/pnfs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,16 @@ pnfs_lseg_range_intersecting(const struct pnfs_layout_range *l1,
593593
return pnfs_is_range_intersecting(l1->offset, end1, l2->offset, end2);
594594
}
595595

596+
static inline bool
597+
pnfs_lseg_request_intersecting(struct pnfs_layout_segment *lseg, struct nfs_page *req)
598+
{
599+
u64 seg_last = pnfs_end_offset(lseg->pls_range.offset, lseg->pls_range.length);
600+
u64 req_last = req_offset(req) + req->wb_bytes;
601+
602+
return pnfs_is_range_intersecting(lseg->pls_range.offset, seg_last,
603+
req_offset(req), req_last);
604+
}
605+
596606
extern unsigned int layoutstats_timer;
597607

598608
#ifdef NFS_DEBUG

fs/nfs/super.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ EXPORT_SYMBOL_GPL(nfs_remount);
23012301
/*
23022302
* Initialise the common bits of the superblock
23032303
*/
2304-
inline void nfs_initialise_sb(struct super_block *sb)
2304+
static void nfs_initialise_sb(struct super_block *sb)
23052305
{
23062306
struct nfs_server *server = NFS_SB(sb);
23072307

@@ -2348,7 +2348,8 @@ EXPORT_SYMBOL_GPL(nfs_fill_super);
23482348
/*
23492349
* Finish setting up a cloned NFS2/3/4 superblock
23502350
*/
2351-
void nfs_clone_super(struct super_block *sb, struct nfs_mount_info *mount_info)
2351+
static void nfs_clone_super(struct super_block *sb,
2352+
struct nfs_mount_info *mount_info)
23522353
{
23532354
const struct super_block *old_sb = mount_info->cloned->sb;
23542355
struct nfs_server *server = NFS_SB(sb);

net/sunrpc/xprtrdma/backchannel.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ int xprt_rdma_bc_setup(struct rpc_xprt *xprt, unsigned int reqs)
119119

120120
for (i = 0; i < (reqs << 1); i++) {
121121
rqst = kzalloc(sizeof(*rqst), GFP_KERNEL);
122-
if (!rqst) {
123-
pr_err("RPC: %s: Failed to create bc rpc_rqst\n",
124-
__func__);
122+
if (!rqst)
125123
goto out_free;
126-
}
124+
127125
dprintk("RPC: %s: new rqst %p\n", __func__, rqst);
128126

129127
rqst->rq_xprt = &r_xprt->rx_xprt;

net/sunrpc/xprtsock.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2432,7 +2432,12 @@ static void xs_tcp_setup_socket(struct work_struct *work)
24322432
case -ENETUNREACH:
24332433
case -EADDRINUSE:
24342434
case -ENOBUFS:
2435-
/* retry with existing socket, after a delay */
2435+
/*
2436+
* xs_tcp_force_close() wakes tasks with -EIO.
2437+
* We need to wake them first to ensure the
2438+
* correct error code.
2439+
*/
2440+
xprt_wake_pending_tasks(xprt, status);
24362441
xs_tcp_force_close(xprt);
24372442
goto out;
24382443
}

0 commit comments

Comments
 (0)