Re: [PATCH 1/2] fs: use mapping_set_error instead of opencoded set_bit
From: Andrew Morton
Date: Mon Sep 12 2016 - 18:11:57 EST
On Mon, 12 Sep 2016 13:16:07 +0200 Michal Hocko <mhocko@xxxxxxxxxx> wrote:
> From: Michal Hocko <mhocko@xxxxxxxx>
>
> mapping_set_error helper sets the correct AS_ flag for the mapping so
> there is no reason to open code it. Use the helper directly.
>
> ...
>
> --- a/drivers/staging/lustre/lustre/llite/vvp_page.c
> +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c
> @@ -247,10 +247,7 @@ static void vvp_vmpage_error(struct inode *inode, struct page *vmpage, int ioret
> obj->vob_discard_page_warned = 0;
> } else {
> SetPageError(vmpage);
> - if (ioret == -ENOSPC)
> - set_bit(AS_ENOSPC, &inode->i_mapping->flags);
> - else
> - set_bit(AS_EIO, &inode->i_mapping->flags);
> + mapping_set_error(inode->i_mapping, ioret);
>
> if ((ioret == -ESHUTDOWN || ioret == -EINTR) &&
> obj->vob_discard_page_warned == 0) {
> diff --git a/fs/afs/write.c b/fs/afs/write.c
> index 14d506efd1aa..20ed04ab833c 100644
> --- a/fs/afs/write.c
> +++ b/fs/afs/write.c
> @@ -398,8 +398,7 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb,
> switch (ret) {
> case -EDQUOT:
> case -ENOSPC:
> - set_bit(AS_ENOSPC,
> - &wb->vnode->vfs_inode.i_mapping->flags);
> + mapping_set_error(wb->vnode->vfs_inode.i_mapping, -ENOSPC);
> break;
> case -EROFS:
> case -EIO:
> @@ -409,7 +408,7 @@ static int afs_write_back_from_locked_page(struct afs_writeback *wb,
> case -ENOMEDIUM:
> case -ENXIO:
> afs_kill_pages(wb->vnode, true, first, last);
> - set_bit(AS_EIO, &wb->vnode->vfs_inode.i_mapping->flags);
> + mapping_set_error(wb->vnode->vfs_inode.i_mapping, -ENXIO);
This one is a functional change: mapping_set_error() will rewrite
-ENXIO into -EIO. Doesn't seem at all important though.
> ...