nfs/localio: fix various new issues
Subsystems (2)
v2 cover nfs/localio: fix various new issues
Hi Anna,
Here are 3 LOCALIO fixes for issues discovered as a side-effect of Zorro's recent bug report:
https://lore.kernel.org/linux-nfs/20251125144508.rxepvtwrubbuhzxs@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
(note that the "generic/751 hang on nfs" still isn't fixed but that one is a long-standing issue that can be reproduced against stock v6.12.53 -- whereas these 3 fixes address code introduced during v6.18-rcX).
Sorry for the trouble, have a wonderful Thanksgiving!
Mike
v2 changes:
- patch 1/3 is the same as was posted here:
https://lore.kernel.org/linux-nfs/[email protected]/
- added patches 2/3 and 3/3
Mike Snitzer (3):
nfs/localio: fix regression due to out-of-order __put_cred nfs/localio: remove alignment size checking in nfs_is_local_dio_possible nfs/localio: remove 61 byte hole from needless ____cacheline_aligned
fs/nfs/localio.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
Signature · 1 line
2.44.0
PATCH v2 1/3 nfs/localio: fix regression due to out-of-order __put_cred
Commit 86855311c117 ("nfs/localio: add refcounting for each iocb IO associated with NFS pgio header") inadvertantly reintroduced the same potential for __put_cred() triggering BUG_ON(cred == current->cred) that commit 992203a1fba5 ("nfs/localio: restore creds before releasing pageio data") fixed.
Fix this by saving and restoring the cred around each {read,write}_iter call within the respective for loop of nfs_local_call_{read,write}.
--- fs/nfs/localio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/nfs/localio.c +6 -6
@@ -625,8 +625,6 @@ static void nfs_local_call_read(struct work_struct *work)ssize_t status;int n_iters; - save_cred =override_creds (filp->f_cred); - n_iters =atomic_read (&iocb->n_iters);for (int i =0 ; i < n_iters ; i++) {if (iocb->iter_is_dio_aligned[i]) {
@@ -639,7 +637,10 @@ static void nfs_local_call_read(struct work_struct *work) }else iocb->kiocb.ki_flags &= ~IOCB_DIRECT ; + save_cred =override_creds (filp->f_cred); status = filp->f_op->read_iter (&iocb->kiocb, &iocb->iters[i]); +revert_creds (save_cred); +if (status != -EIOCBQUEUED ) {if (unlikely (status >=0 && status < iocb->iters[i].count)) force_done = true;/* Partial read */
@@ -649,8 +650,6 @@ static void nfs_local_call_read(struct work_struct *work) } } } - -revert_creds (save_cred); } static int
@@ -832,7 +831,6 @@ static void nfs_local_call_write(struct work_struct *work)int n_iters; current->flags |=PF_LOCAL_THROTTLE |PF_MEMALLOC_NOIO ; - save_cred =override_creds (filp->f_cred);file_start_write (filp); n_iters =atomic_read (&iocb->n_iters);
@@ -847,7 +845,10 @@ static void nfs_local_call_write(struct work_struct *work) }else iocb->kiocb.ki_flags &= ~IOCB_DIRECT ; + save_cred =override_creds (filp->f_cred); status = filp->f_op->write_iter (&iocb->kiocb, &iocb->iters[i]); +revert_creds (save_cred); +if (status != -EIOCBQUEUED ) {if (unlikely (status >=0 && status < iocb->iters[i].count)) force_done = true;/* Partial write */
@@ -859,7 +860,6 @@ static void nfs_local_call_write(struct work_struct *work) }file_end_write (filp); -revert_creds (save_cred); current->flags = old_flags; }
Signature · 1 line
2.44.0
PATCH v2 2/3 nfs/localio: remove alignment size checking in nfs_is_local_dio_possible
In reply to Mike SnitzerFrom: Mike Snitzer <[email protected]>
This check to ensure dio_offset_align isn't larger than PAGE_SIZE is no longer relevant (older iterations of NFS Direct was allocating misaligned head and tail pages but no longer does, so this check isn't needed).
--- fs/nfs/localio.c | 2 -- 1 file changed, 2 deletions(-)
fs/nfs/localio.c +0 -2
@@ -339,8 +339,6 @@ nfs_is_local_dio_possible(struct nfs_local_kiocb *iocb, int rw,if (unlikely (!nf_dio_mem_align || !nf_dio_offset_align))return false; -if (unlikely (nf_dio_offset_align >PAGE_SIZE )) -return false;if (unlikely (len < nf_dio_offset_align))return false;
Signature · 1 line
2.44.0
PATCH v2 3/3 nfs/localio: remove 61 byte hole from needless ____cacheline_aligned
In reply to Mike Snitzerstruct nfs_local_kiocb used ____cacheline_aligned on its iters[] array and as the structure evolved it caused a 61 byte hole to form. Fix this by removing ____cacheline_aligned and reordering iters[] before iter_is_dio_aligned[].
--- fs/nfs/localio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/localio.c +1 -1
@@ -43,8 +43,8 @@ struct nfs_local_kiocb {size_t end_len;short int end_iter_index;atomic_t n_iters; +struct iov_iter iters[NFSLOCAL_MAX_IOS ];bool iter_is_dio_aligned[NFSLOCAL_MAX_IOS ]; -struct iov_iter iters[NFSLOCAL_MAX_IOS ]____cacheline_aligned ;/* End mostly DIO-specific members */ };
Signature · 1 line
2.44.0
Quoted 5 lines · Mike Snitzer
Hi Anna,
Here are 3 LOCALIO fixes for issues discovered as a side-effect of Zorro's recent bug report:
https://lore.kernel.org/linux-nfs/20251125144508.rxepvtwrubbuhzxs@dell-per750-06-vm-08.rhts.eng.pek2.redhat.com/
Hi Mike,
I just tested this patchset (base on linux v6.18-rc7 which can reproduce that cred crash bug). Then the test didn't trigger the crash. So I think this patchset works for that crash bug. (But the g/751 hang bug is still there.)
Quoted 7 lines
(note that the "generic/751 hang on nfs" still isn't fixed but that one is a long-standing issue that can be reproduced against stock v6.12.53 -- whereas these 3 fixes address code introduced during v6.18-rcX).
Sorry for the trouble, have a wonderful Thanksgiving!
Have a nice Thanksgiving day!
Thanks,
Zorro
Quoted 19 lines
Mike
v2 changes:
- patch 1/3 is the same as was posted here:
https://lore.kernel.org/linux-nfs/[email protected]/
- added patches 2/3 and 3/3Mike Snitzer (3):
nfs/localio: fix regression due to out-of-order__put_crednfs/localio: remove alignment size checking innfs_is_local_dio_possiblenfs/localio: remove 61 byte hole from needless____cacheline_alignedfs/nfs/localio.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)Signature · 1 line
2.44.0