diff mbox

[2/3] Btrfs: don't set and clear delalloc for O_DIRECT writes

Message ID 1423685339-8278-2-git-send-email-jbacik@fb.com (mailing list archive)
State Accepted
Headers show

Commit Message

Josef Bacik Feb. 11, 2015, 8:08 p.m. UTC
We do this to get the space accounting, but this is just needless churn on the
io_tree, so just drop setting/clearing delalloc and just drop the reserved data
space when we have a successfull allocation.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 fs/btrfs/inode.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Liu Bo Feb. 12, 2015, 4:45 a.m. UTC | #1
On Wed, Feb 11, 2015 at 03:08:58PM -0500, Josef Bacik wrote:
> We do this to get the space accounting, but this is just needless churn on the
> io_tree, so just drop setting/clearing delalloc and just drop the reserved data
> space when we have a successfull allocation.  Thanks,
> 

Looks good.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
>  fs/btrfs/inode.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index e78a2fd..fb16fd3 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7142,7 +7142,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
>  	int ret = 0;
>  
>  	if (create)
> -		unlock_bits |= EXTENT_DELALLOC | EXTENT_DIRTY;
> +		unlock_bits |= EXTENT_DIRTY;
>  	else
>  		len = min_t(u64, len, root->sectorsize);
>  
> @@ -7278,11 +7278,7 @@ unlock:
>  			BTRFS_I(inode)->outstanding_extents++;
>  			spin_unlock(&BTRFS_I(inode)->lock);
>  		}
> -
> -		ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
> -				     lockstart + len - 1, EXTENT_DELALLOC, NULL,
> -				     &cached_state, GFP_NOFS);
> -		BUG_ON(ret);
> +		btrfs_free_reserved_data_space(inode, len);
>  	}
>  
>  	/*
> -- 
> 1.8.3.1
> 
> --
> 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
--
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 mbox

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e78a2fd..fb16fd3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7142,7 +7142,7 @@  static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
 	int ret = 0;
 
 	if (create)
-		unlock_bits |= EXTENT_DELALLOC | EXTENT_DIRTY;
+		unlock_bits |= EXTENT_DIRTY;
 	else
 		len = min_t(u64, len, root->sectorsize);
 
@@ -7278,11 +7278,7 @@  unlock:
 			BTRFS_I(inode)->outstanding_extents++;
 			spin_unlock(&BTRFS_I(inode)->lock);
 		}
-
-		ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
-				     lockstart + len - 1, EXTENT_DELALLOC, NULL,
-				     &cached_state, GFP_NOFS);
-		BUG_ON(ret);
+		btrfs_free_reserved_data_space(inode, len);
 	}
 
 	/*