Skip to content

Commit fb0155a

Browse files
committed
Merge tag 'nfs-for-5.9-3' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client bugfixes from Trond Myklebust: "Highlights include: - NFSv4.2: copy_file_range needs to invalidate caches on success - NFSv4.2: Fix security label length not being reset - pNFS/flexfiles: Ensure we initialise the mirror bsizes correctly on read - pNFS/flexfiles: Fix signed/unsigned type issues with mirror indices" * tag 'nfs-for-5.9-3' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: pNFS/flexfiles: Be consistent about mirror index types pNFS/flexfiles: Ensure we initialise the mirror bsizes correctly on read NFSv4.2: fix client's attribute cache management for copy_file_range nfs: Fix security label length not being reset
2 parents a4d63c3 + b9df46d commit fb0155a

4 files changed

Lines changed: 36 additions & 24 deletions

File tree

‎fs/nfs/dir.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,9 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en
579579
xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
580580

581581
do {
582+
if (entry->label)
583+
entry->label->len = NFS4_MAXLABELLEN;
584+
582585
status = xdr_decode(desc, entry, &stream);
583586
if (status != 0) {
584587
if (status == -EAGAIN)

‎fs/nfs/flexfilelayout/flexfilelayout.c‎

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ nfs4_ff_layout_stat_io_end_write(struct rpc_task *task,
715715
}
716716

717717
static void
718-
ff_layout_mark_ds_unreachable(struct pnfs_layout_segment *lseg, int idx)
718+
ff_layout_mark_ds_unreachable(struct pnfs_layout_segment *lseg, u32 idx)
719719
{
720720
struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx);
721721

@@ -724,7 +724,7 @@ ff_layout_mark_ds_unreachable(struct pnfs_layout_segment *lseg, int idx)
724724
}
725725

726726
static void
727-
ff_layout_mark_ds_reachable(struct pnfs_layout_segment *lseg, int idx)
727+
ff_layout_mark_ds_reachable(struct pnfs_layout_segment *lseg, u32 idx)
728728
{
729729
struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx);
730730

@@ -734,14 +734,14 @@ ff_layout_mark_ds_reachable(struct pnfs_layout_segment *lseg, int idx)
734734

735735
static struct nfs4_pnfs_ds *
736736
ff_layout_choose_ds_for_read(struct pnfs_layout_segment *lseg,
737-
int start_idx, int *best_idx,
737+
u32 start_idx, u32 *best_idx,
738738
bool check_device)
739739
{
740740
struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg);
741741
struct nfs4_ff_layout_mirror *mirror;
742742
struct nfs4_pnfs_ds *ds;
743743
bool fail_return = false;
744-
int idx;
744+
u32 idx;
745745

746746
/* mirrors are initially sorted by efficiency */
747747
for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) {
@@ -766,21 +766,21 @@ ff_layout_choose_ds_for_read(struct pnfs_layout_segment *lseg,
766766

767767
static struct nfs4_pnfs_ds *
768768
ff_layout_choose_any_ds_for_read(struct pnfs_layout_segment *lseg,
769-
int start_idx, int *best_idx)
769+
u32 start_idx, u32 *best_idx)
770770
{
771771
return ff_layout_choose_ds_for_read(lseg, start_idx, best_idx, false);
772772
}
773773

774774
static struct nfs4_pnfs_ds *
775775
ff_layout_choose_valid_ds_for_read(struct pnfs_layout_segment *lseg,
776-
int start_idx, int *best_idx)
776+
u32 start_idx, u32 *best_idx)
777777
{
778778
return ff_layout_choose_ds_for_read(lseg, start_idx, best_idx, true);
779779
}
780780

781781
static struct nfs4_pnfs_ds *
782782
ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg,
783-
int start_idx, int *best_idx)
783+
u32 start_idx, u32 *best_idx)
784784
{
785785
struct nfs4_pnfs_ds *ds;
786786

@@ -791,7 +791,8 @@ ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg,
791791
}
792792

793793
static struct nfs4_pnfs_ds *
794-
ff_layout_get_ds_for_read(struct nfs_pageio_descriptor *pgio, int *best_idx)
794+
ff_layout_get_ds_for_read(struct nfs_pageio_descriptor *pgio,
795+
u32 *best_idx)
795796
{
796797
struct pnfs_layout_segment *lseg = pgio->pg_lseg;
797798
struct nfs4_pnfs_ds *ds;
@@ -837,7 +838,7 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio,
837838
struct nfs_pgio_mirror *pgm;
838839
struct nfs4_ff_layout_mirror *mirror;
839840
struct nfs4_pnfs_ds *ds;
840-
int ds_idx;
841+
u32 ds_idx, i;
841842

842843
retry:
843844
ff_layout_pg_check_layout(pgio, req);
@@ -863,14 +864,14 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio,
863864
goto retry;
864865
}
865866

866-
mirror = FF_LAYOUT_COMP(pgio->pg_lseg, ds_idx);
867+
for (i = 0; i < pgio->pg_mirror_count; i++) {
868+
mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i);
869+
pgm = &pgio->pg_mirrors[i];
870+
pgm->pg_bsize = mirror->mirror_ds->ds_versions[0].rsize;
871+
}
867872

868873
pgio->pg_mirror_idx = ds_idx;
869874

870-
/* read always uses only one mirror - idx 0 for pgio layer */
871-
pgm = &pgio->pg_mirrors[0];
872-
pgm->pg_bsize = mirror->mirror_ds->ds_versions[0].rsize;
873-
874875
if (NFS_SERVER(pgio->pg_inode)->flags &
875876
(NFS_MOUNT_SOFT|NFS_MOUNT_SOFTERR))
876877
pgio->pg_maxretrans = io_maxretrans;
@@ -894,7 +895,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
894895
struct nfs4_ff_layout_mirror *mirror;
895896
struct nfs_pgio_mirror *pgm;
896897
struct nfs4_pnfs_ds *ds;
897-
int i;
898+
u32 i;
898899

899900
retry:
900901
ff_layout_pg_check_layout(pgio, req);
@@ -1038,7 +1039,7 @@ static void ff_layout_reset_write(struct nfs_pgio_header *hdr, bool retry_pnfs)
10381039
static void ff_layout_resend_pnfs_read(struct nfs_pgio_header *hdr)
10391040
{
10401041
u32 idx = hdr->pgio_mirror_idx + 1;
1041-
int new_idx = 0;
1042+
u32 new_idx = 0;
10421043

10431044
if (ff_layout_choose_any_ds_for_read(hdr->lseg, idx + 1, &new_idx))
10441045
ff_layout_send_layouterror(hdr->lseg);
@@ -1075,7 +1076,7 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,
10751076
struct nfs4_state *state,
10761077
struct nfs_client *clp,
10771078
struct pnfs_layout_segment *lseg,
1078-
int idx)
1079+
u32 idx)
10791080
{
10801081
struct pnfs_layout_hdr *lo = lseg->pls_layout;
10811082
struct inode *inode = lo->plh_inode;
@@ -1149,7 +1150,7 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,
11491150
/* Retry all errors through either pNFS or MDS except for -EJUKEBOX */
11501151
static int ff_layout_async_handle_error_v3(struct rpc_task *task,
11511152
struct pnfs_layout_segment *lseg,
1152-
int idx)
1153+
u32 idx)
11531154
{
11541155
struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx);
11551156

@@ -1184,7 +1185,7 @@ static int ff_layout_async_handle_error(struct rpc_task *task,
11841185
struct nfs4_state *state,
11851186
struct nfs_client *clp,
11861187
struct pnfs_layout_segment *lseg,
1187-
int idx)
1188+
u32 idx)
11881189
{
11891190
int vers = clp->cl_nfs_mod->rpc_vers->number;
11901191

@@ -1211,7 +1212,7 @@ static int ff_layout_async_handle_error(struct rpc_task *task,
12111212
}
12121213

12131214
static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,
1214-
int idx, u64 offset, u64 length,
1215+
u32 idx, u64 offset, u64 length,
12151216
u32 *op_status, int opnum, int error)
12161217
{
12171218
struct nfs4_ff_layout_mirror *mirror;
@@ -1809,7 +1810,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
18091810
loff_t offset = hdr->args.offset;
18101811
int vers;
18111812
struct nfs_fh *fh;
1812-
int idx = hdr->pgio_mirror_idx;
1813+
u32 idx = hdr->pgio_mirror_idx;
18131814

18141815
mirror = FF_LAYOUT_COMP(lseg, idx);
18151816
ds = nfs4_ff_layout_prepare_ds(lseg, mirror, true);

‎fs/nfs/nfs42proc.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,15 @@ static ssize_t _nfs42_proc_copy(struct file *src,
356356

357357
truncate_pagecache_range(dst_inode, pos_dst,
358358
pos_dst + res->write_res.count);
359-
359+
spin_lock(&dst_inode->i_lock);
360+
NFS_I(dst_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE |
361+
NFS_INO_REVAL_FORCED | NFS_INO_INVALID_SIZE |
362+
NFS_INO_INVALID_ATTR | NFS_INO_INVALID_DATA);
363+
spin_unlock(&dst_inode->i_lock);
364+
spin_lock(&src_inode->i_lock);
365+
NFS_I(src_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE |
366+
NFS_INO_REVAL_FORCED | NFS_INO_INVALID_ATIME);
367+
spin_unlock(&src_inode->i_lock);
360368
status = res->write_res.count;
361369
out:
362370
if (args->sync)

‎include/linux/nfs_xdr.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,8 +1611,8 @@ struct nfs_pgio_header {
16111611
__u64 mds_offset; /* Filelayout dense stripe */
16121612
struct nfs_page_array page_array;
16131613
struct nfs_client *ds_clp; /* pNFS data server */
1614-
int ds_commit_idx; /* ds index if ds_clp is set */
1615-
int pgio_mirror_idx;/* mirror index in pgio layer */
1614+
u32 ds_commit_idx; /* ds index if ds_clp is set */
1615+
u32 pgio_mirror_idx;/* mirror index in pgio layer */
16161616
};
16171617

16181618
struct nfs_mds_commit_info {

0 commit comments

Comments
 (0)