Message ID | 20180530084856.17264-1-suy.fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 30.05.2018 11:48, Su Yue wrote: > In cow_file_range(), create_io_em() may fail, but its return value is > not recorded. > Then return value may be 0 even it failed which is a wrong behavior. > > Let cow_file_range() return PTR_ERR(em) if create_io_em() failed. > > Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> This also needs: Fixes: 6f9994dbabe5 ("Btrfs: create a helper to create em for IO") And should be applied to stable starting from 4.11 > --- > fs/btrfs/inode.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c > index 9228cb866115..14ffb4858d09 100644 > --- a/fs/btrfs/inode.c > +++ b/fs/btrfs/inode.c > @@ -1018,8 +1018,10 @@ static noinline int cow_file_range(struct inode *inode, > ram_size, /* ram_bytes */ > BTRFS_COMPRESS_NONE, /* compress_type */ > BTRFS_ORDERED_REGULAR /* type */); > - if (IS_ERR(em)) > + if (IS_ERR(em)) { > + ret = PTR_ERR(em); > goto out_reserve; > + } > free_extent_map(em); > > ret = btrfs_add_ordered_extent(inode, start, ins.objectid, > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, May 30, 2018 at 04:48:56PM +0800, Su Yue wrote: > In cow_file_range(), create_io_em() may fail, but its return value is > not recorded. > Then return value may be 0 even it failed which is a wrong behavior. > > Let cow_file_range() return PTR_ERR(em) if create_io_em() failed. > > Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Added to queue, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9228cb866115..14ffb4858d09 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1018,8 +1018,10 @@ static noinline int cow_file_range(struct inode *inode, ram_size, /* ram_bytes */ BTRFS_COMPRESS_NONE, /* compress_type */ BTRFS_ORDERED_REGULAR /* type */); - if (IS_ERR(em)) + if (IS_ERR(em)) { + ret = PTR_ERR(em); goto out_reserve; + } free_extent_map(em); ret = btrfs_add_ordered_extent(inode, start, ins.objectid,
In cow_file_range(), create_io_em() may fail, but its return value is not recorded. Then return value may be 0 even it failed which is a wrong behavior. Let cow_file_range() return PTR_ERR(em) if create_io_em() failed. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> --- fs/btrfs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)