[PATCH 1/2] bcachefs: use FGP_WRITEBEGIN instead of combining individual flags

Pankaj Raghav (Samsung) posted 2 patches 1 year, 6 months ago
There is a newer version of this series
[PATCH 1/2] bcachefs: use FGP_WRITEBEGIN instead of combining individual flags
Posted by Pankaj Raghav (Samsung) 1 year, 6 months ago
From: Pankaj Raghav <p.raghav@samsung.com>

Use FGP_WRITEBEGIN to avoid repeating the individual FGP flags before
starting a buffered write.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 fs/bcachefs/fs-io-buffered.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/bcachefs/fs-io-buffered.c b/fs/bcachefs/fs-io-buffered.c
index 54873ecc635c..865691dd0173 100644
--- a/fs/bcachefs/fs-io-buffered.c
+++ b/fs/bcachefs/fs-io-buffered.c
@@ -677,9 +677,8 @@ int bch2_write_begin(struct file *file, struct address_space *mapping,
 
 	bch2_pagecache_add_get(inode);
 
-	folio = __filemap_get_folio(mapping, pos >> PAGE_SHIFT,
-				FGP_LOCK|FGP_WRITE|FGP_CREAT|FGP_STABLE,
-				mapping_gfp_mask(mapping));
+	folio = __filemap_get_folio(mapping, pos >> PAGE_SHIFT, FGP_WRITEBEGIN,
+				    mapping_gfp_mask(mapping));
 	if (IS_ERR_OR_NULL(folio))
 		goto err_unlock;
 
@@ -820,9 +819,8 @@ static int __bch2_buffered_write(struct bch_inode_info *inode,
 	darray_init(&fs);
 
 	ret = bch2_filemap_get_contig_folios_d(mapping, pos, end,
-				   FGP_LOCK|FGP_WRITE|FGP_STABLE|FGP_CREAT,
-				   mapping_gfp_mask(mapping),
-				   &fs);
+					       FGP_WRITEBEGIN,
+					       mapping_gfp_mask(mapping), &fs);
 	if (ret)
 		goto out;
 
-- 
2.44.1
Re: [PATCH 1/2] bcachefs: use FGP_WRITEBEGIN instead of combining individual flags
Posted by Matthew Wilcox 1 year, 6 months ago
On Fri, Jun 14, 2024 at 10:50:30AM +0000, Pankaj Raghav (Samsung) wrote:
>  	ret = bch2_filemap_get_contig_folios_d(mapping, pos, end,
> -				   FGP_LOCK|FGP_WRITE|FGP_STABLE|FGP_CREAT,
> -				   mapping_gfp_mask(mapping),
> -				   &fs);
> +					       FGP_WRITEBEGIN,
> +					       mapping_gfp_mask(mapping), &fs);

Don't change the indentation here.  In the next patch it makes the
lines too long.

In general, don't change the indentation.  It's been one of the biggest
pains of the folio conversion.  "Oh, you changed the name of this
function and now the arguments don't line up".  Don't line up the
arguments with the opening paren.
Re: [PATCH 1/2] bcachefs: use FGP_WRITEBEGIN instead of combining individual flags
Posted by Pankaj Raghav (Samsung) 1 year, 6 months ago
On Fri, Jun 14, 2024 at 03:36:22PM +0100, Matthew Wilcox wrote:
> On Fri, Jun 14, 2024 at 10:50:30AM +0000, Pankaj Raghav (Samsung) wrote:
> >  	ret = bch2_filemap_get_contig_folios_d(mapping, pos, end,
> > -				   FGP_LOCK|FGP_WRITE|FGP_STABLE|FGP_CREAT,
> > -				   mapping_gfp_mask(mapping),
> > -				   &fs);
> > +					       FGP_WRITEBEGIN,
> > +					       mapping_gfp_mask(mapping), &fs);
> 
> Don't change the indentation here.  In the next patch it makes the
> lines too long.

I used clangd to do the formatting. I will probably stick without
changing the format in this patch

Thanks.
> 
> In general, don't change the indentation.  It's been one of the biggest
> pains of the folio conversion.  "Oh, you changed the name of this
> function and now the arguments don't line up".  Don't line up the
> arguments with the opening paren.