public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: check return value of filemap_fdatawrite_range()
@ 2020-08-21 12:41 Alex Dewar
  2020-08-21 14:11 ` Josef Bacik
  2020-08-21 14:38 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Alex Dewar @ 2020-08-21 12:41 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, Goldwyn Rodrigues,
	linux-btrfs, linux-kernel
  Cc: Alex Dewar

In btrfs_dio_imap_begin(), filemap_fdatawrite_range() is called without
checking the return value. Add a check to catch errors.

Fixes: c0aaf9b7a114f ("btrfs: switch to iomap_dio_rw() for dio")
Addresses-Coverity: ("Unused value")
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
 fs/btrfs/inode.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 7b57aaa1f9acc..38fde20b4a81b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7347,9 +7347,12 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
 	 * outstanding dirty pages are on disk.
 	 */
 	if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
-		     &BTRFS_I(inode)->runtime_flags))
+		     &BTRFS_I(inode)->runtime_flags)) {
 		ret = filemap_fdatawrite_range(inode->i_mapping, start,
 					       start + length - 1);
+		if (ret)
+			return ret;
+	}
 
 	dio_data = kzalloc(sizeof(*dio_data), GFP_NOFS);
 	if (!dio_data)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: check return value of filemap_fdatawrite_range()
  2020-08-21 12:41 [PATCH] btrfs: check return value of filemap_fdatawrite_range() Alex Dewar
@ 2020-08-21 14:11 ` Josef Bacik
  2020-08-21 14:38 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2020-08-21 14:11 UTC (permalink / raw)
  To: Alex Dewar, Chris Mason, David Sterba, Goldwyn Rodrigues,
	linux-btrfs, linux-kernel

On 8/21/20 8:41 AM, Alex Dewar wrote:
> In btrfs_dio_imap_begin(), filemap_fdatawrite_range() is called without
> checking the return value. Add a check to catch errors.
> 
> Fixes: c0aaf9b7a114f ("btrfs: switch to iomap_dio_rw() for dio")
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> ---
>   fs/btrfs/inode.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 7b57aaa1f9acc..38fde20b4a81b 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7347,9 +7347,12 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
>   	 * outstanding dirty pages are on disk.
>   	 */
>   	if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
> -		     &BTRFS_I(inode)->runtime_flags))
> +		     &BTRFS_I(inode)->runtime_flags)) {
>   		ret = filemap_fdatawrite_range(inode->i_mapping, start,
>   					       start + length - 1);
> +		if (ret)
> +			return ret;
> +	}
>   
>   	dio_data = kzalloc(sizeof(*dio_data), GFP_NOFS);
>   	if (!dio_data)
> 

Had to check to make sure there's no cleanup that's needed, there isn't, 
you can add

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: check return value of filemap_fdatawrite_range()
  2020-08-21 12:41 [PATCH] btrfs: check return value of filemap_fdatawrite_range() Alex Dewar
  2020-08-21 14:11 ` Josef Bacik
@ 2020-08-21 14:38 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2020-08-21 14:38 UTC (permalink / raw)
  To: Alex Dewar
  Cc: Chris Mason, Josef Bacik, David Sterba, Goldwyn Rodrigues,
	linux-btrfs, linux-kernel

On Fri, Aug 21, 2020 at 01:41:54PM +0100, Alex Dewar wrote:
> In btrfs_dio_imap_begin(), filemap_fdatawrite_range() is called without
> checking the return value. Add a check to catch errors.
> 
> Fixes: c0aaf9b7a114f ("btrfs: switch to iomap_dio_rw() for dio")
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>

Folded to the patch, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-21 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-21 12:41 [PATCH] btrfs: check return value of filemap_fdatawrite_range() Alex Dewar
2020-08-21 14:11 ` Josef Bacik
2020-08-21 14:38 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox