Skip to content

Commit f74e3ea

Browse files
committed
Merge tag 'nfs-for-6.6-4' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client fixes from Anna Schumaker: "Stable Fix: - Fix a pNFS hang in nfs4_evict_inode() Fixes: - Force update of suid/sgid bits after an NFS v4.2 ALLOCATE op - Fix a potential oops in nfs_inode_remove_request() - Check the validity of the layout pointer in ff_layout_mirror_prepare_stats() - Fix incorrectly marking the pNFS MDS with USE_PNFS_DS in some cases" * tag 'nfs-for-6.6-4' of git://git.linux-nfs.org/projects/anna/linux-nfs: NFSv4.1: fixup use EXCHGID4_FLAG_USE_PNFS_DS for DS server pNFS/flexfiles: Check the layout validity in ff_layout_mirror_prepare_stats pNFS: Fix a hang in nfs4_evict_inode() NFS: Fix potential oops in nfs_inode_remove_request() nfs42: client needs to strip file mode's suid/sgid bit after ALLOCATE op
2 parents 0e97fd2 + 379e4ad commit f74e3ea

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,9 +2520,9 @@ ff_layout_mirror_prepare_stats(struct pnfs_layout_hdr *lo,
25202520
return i;
25212521
}
25222522

2523-
static int
2524-
ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args)
2523+
static int ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args)
25252524
{
2525+
struct pnfs_layout_hdr *lo;
25262526
struct nfs4_flexfile_layout *ff_layout;
25272527
const int dev_count = PNFS_LAYOUTSTATS_MAXDEV;
25282528

@@ -2533,11 +2533,14 @@ ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args *args)
25332533
return -ENOMEM;
25342534

25352535
spin_lock(&args->inode->i_lock);
2536-
ff_layout = FF_LAYOUT_FROM_HDR(NFS_I(args->inode)->layout);
2537-
args->num_dev = ff_layout_mirror_prepare_stats(&ff_layout->generic_hdr,
2538-
&args->devinfo[0],
2539-
dev_count,
2540-
NFS4_FF_OP_LAYOUTSTATS);
2536+
lo = NFS_I(args->inode)->layout;
2537+
if (lo && pnfs_layout_is_valid(lo)) {
2538+
ff_layout = FF_LAYOUT_FROM_HDR(lo);
2539+
args->num_dev = ff_layout_mirror_prepare_stats(
2540+
&ff_layout->generic_hdr, &args->devinfo[0], dev_count,
2541+
NFS4_FF_OP_LAYOUTSTATS);
2542+
} else
2543+
args->num_dev = 0;
25412544
spin_unlock(&args->inode->i_lock);
25422545
if (!args->num_dev) {
25432546
kfree(args->devinfo);

fs/nfs/nfs42proc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
8181
if (status == 0) {
8282
if (nfs_should_remove_suid(inode)) {
8383
spin_lock(&inode->i_lock);
84-
nfs_set_cache_invalid(inode, NFS_INO_INVALID_MODE);
84+
nfs_set_cache_invalid(inode,
85+
NFS_INO_REVAL_FORCED | NFS_INO_INVALID_MODE);
8586
spin_unlock(&inode->i_lock);
8687
}
8788
status = nfs_post_op_update_inode_force_wcc(inode,

fs/nfs/nfs4proc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8870,8 +8870,6 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cre
88708870
/* Save the EXCHANGE_ID verifier session trunk tests */
88718871
memcpy(clp->cl_confirm.data, argp->verifier.data,
88728872
sizeof(clp->cl_confirm.data));
8873-
if (resp->flags & EXCHGID4_FLAG_USE_PNFS_DS)
8874-
set_bit(NFS_CS_DS, &clp->cl_flags);
88758873
out:
88768874
trace_nfs4_exchange_id(clp, status);
88778875
rpc_put_task(task);

fs/nfs/pnfs.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,31 +2634,44 @@ pnfs_should_return_unused_layout(struct pnfs_layout_hdr *lo,
26342634
return mode == 0;
26352635
}
26362636

2637-
static int
2638-
pnfs_layout_return_unused_byserver(struct nfs_server *server, void *data)
2637+
static int pnfs_layout_return_unused_byserver(struct nfs_server *server,
2638+
void *data)
26392639
{
26402640
const struct pnfs_layout_range *range = data;
2641+
const struct cred *cred;
26412642
struct pnfs_layout_hdr *lo;
26422643
struct inode *inode;
2644+
nfs4_stateid stateid;
2645+
enum pnfs_iomode iomode;
2646+
26432647
restart:
26442648
rcu_read_lock();
26452649
list_for_each_entry_rcu(lo, &server->layouts, plh_layouts) {
2646-
if (!pnfs_layout_can_be_returned(lo) ||
2650+
inode = lo->plh_inode;
2651+
if (!inode || !pnfs_layout_can_be_returned(lo) ||
26472652
test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags))
26482653
continue;
2649-
inode = lo->plh_inode;
26502654
spin_lock(&inode->i_lock);
2651-
if (!pnfs_should_return_unused_layout(lo, range)) {
2655+
if (!lo->plh_inode ||
2656+
!pnfs_should_return_unused_layout(lo, range)) {
26522657
spin_unlock(&inode->i_lock);
26532658
continue;
26542659
}
2660+
pnfs_get_layout_hdr(lo);
2661+
pnfs_set_plh_return_info(lo, range->iomode, 0);
2662+
if (pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs,
2663+
range, 0) != 0 ||
2664+
!pnfs_prepare_layoutreturn(lo, &stateid, &cred, &iomode)) {
2665+
spin_unlock(&inode->i_lock);
2666+
rcu_read_unlock();
2667+
pnfs_put_layout_hdr(lo);
2668+
cond_resched();
2669+
goto restart;
2670+
}
26552671
spin_unlock(&inode->i_lock);
2656-
inode = pnfs_grab_inode_layout_hdr(lo);
2657-
if (!inode)
2658-
continue;
26592672
rcu_read_unlock();
2660-
pnfs_mark_layout_for_return(inode, range);
2661-
iput(inode);
2673+
pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, false);
2674+
pnfs_put_layout_hdr(lo);
26622675
cond_resched();
26632676
goto restart;
26642677
}

fs/nfs/write.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@ static void nfs_inode_add_request(struct nfs_page *req)
788788
*/
789789
static void nfs_inode_remove_request(struct nfs_page *req)
790790
{
791+
struct nfs_inode *nfsi = NFS_I(nfs_page_to_inode(req));
792+
791793
if (nfs_page_group_sync_on_bit(req, PG_REMOVE)) {
792794
struct folio *folio = nfs_page_to_folio(req->wb_head);
793795
struct address_space *mapping = folio_file_mapping(folio);
@@ -802,7 +804,7 @@ static void nfs_inode_remove_request(struct nfs_page *req)
802804
}
803805

804806
if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) {
805-
atomic_long_dec(&NFS_I(nfs_page_to_inode(req))->nrequests);
807+
atomic_long_dec(&nfsi->nrequests);
806808
nfs_release_request(req);
807809
}
808810
}

0 commit comments

Comments
 (0)