Re: [PATCH] afs: Fix ENOSPC, EDQUOT and other errors to fail a write rather than retrying

From: Jeffrey E Altman
Date: Wed Nov 03 2021 - 22:34:43 EST


Looks good to me.

Reviewed-by Jeffrey Altman

On 11/3/2021 4:43 PM, David Howells (dhowells@xxxxxxxxxx) wrote:
> Currently, at the completion of a storage RPC from writepages, the errors
> ENOSPC, EDQUOT, ENOKEY, EACCES, EPERM, EKEYREJECTED and EKEYREVOKED cause
> the pages involved to be redirtied and the write to be retried by the VM at
> a future time.
>
> However, this is probably not the right thing to do, and, instead, the
> writes should be discarded so that the system doesn't get blocked (though
> unmounting will discard the uncommitted writes anyway).
>
> Fix this by making afs_write_back_from_locked_page() call afs_kill_pages()
> instead of afs_redirty_pages() in those cases.
>
> EKEYEXPIRED is left to redirty the pages on the assumption that the caller
> just needs to renew their key. Unknown errors also do that, though it
> might be better to squelch those too.
>
> This can be triggered by the generic/285 xfstest. The writes can be
> observed in the server logs. If a write fails with ENOSPC (ie. CODE
> 49733403, UAENOSPC) because a file is made really large, e.g.:
>
> Wed Nov 03 23:21:35.794133 2021 [1589] EVENT YFS_SRX_StData CODE 49733403 NAME --UnAuth-- HOST [192.168.1.2]:7001 ID 32766 FID 1048664:0.172306:30364251 UINT64 17592187027456 UINT64 65536 UINT64 17592187092992 UINT64 0
>
> this should be seen once and not repeated.
>
> Reported-by: Marc Dionne <marc.dionne@xxxxxxxxxxxx>
> Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
> cc: Jeffrey E Altman <jaltman@xxxxxxxxxxxx>
> cc: linux-afs@xxxxxxxxxxxxxxxxxxx
> ---
>
> fs/afs/write.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/fs/afs/write.c b/fs/afs/write.c
> index 8b1d9c2f6bec..04f3f87b15cb 100644
> --- a/fs/afs/write.c
> +++ b/fs/afs/write.c
> @@ -620,22 +620,18 @@ static ssize_t afs_write_back_from_locked_page(struct address_space *mapping,
> default:
> pr_notice("kAFS: Unexpected error from FS.StoreData %d\n", ret);
> fallthrough;
> - case -EACCES:
> - case -EPERM:
> - case -ENOKEY:
> case -EKEYEXPIRED:
> - case -EKEYREJECTED:
> - case -EKEYREVOKED:
> afs_redirty_pages(wbc, mapping, start, len);
> mapping_set_error(mapping, ret);
> break;
>
> + case -EACCES:
> + case -EPERM:
> + case -ENOKEY:
> + case -EKEYREJECTED:
> + case -EKEYREVOKED:
> case -EDQUOT:
> case -ENOSPC:
> - afs_redirty_pages(wbc, mapping, start, len);
> - mapping_set_error(mapping, -ENOSPC);
> - break;
> -
> case -EROFS:
> case -EIO:
> case -EREMOTEIO:
>
>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature