[Cluster-devel] [PATCH] gfs2: Clean up gfs2_is_{ordered, writeback}

2018-10-12 Thread Andreas Gruenbacher
The gfs2_is_ordered and gfs2_is_writeback checks are weird in that they
implicitly check for !gfs2_is_jdata.  This makes understanding how to
use those functions correctly a challenge.  Clean this up by making
gfs2_is_ordered and gfs2_is_writeback take a super block instead of an
inode and by removing the implicit !gfs2_is_jdata checks.  Update the
callers accordingly.

Signed-off-by: Andreas Gruenbacher 
---
 fs/gfs2/aops.c  | 10 +-
 fs/gfs2/inode.h | 10 --
 fs/gfs2/log.h   |  5 ++---
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 31e8270d0b26..f47370995c18 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -930,14 +930,14 @@ static const struct address_space_operations 
gfs2_jdata_aops = {
 void gfs2_set_aops(struct inode *inode)
 {
struct gfs2_inode *ip = GFS2_I(inode);
+   struct gfs2_sbd *sdp = GFS2_SB(inode);
 
-   if (gfs2_is_writeback(ip))
+   if (gfs2_is_jdata(ip))
+   inode->i_mapping->a_ops = _jdata_aops;
+   else if (gfs2_is_writeback(sdp))
inode->i_mapping->a_ops = _writeback_aops;
-   else if (gfs2_is_ordered(ip))
+   else if (gfs2_is_ordered(sdp))
inode->i_mapping->a_ops = _ordered_aops;
-   else if (gfs2_is_jdata(ip))
-   inode->i_mapping->a_ops = _jdata_aops;
else
BUG();
 }
-
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index b5b6341a4f5c..793808263c6d 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -30,16 +30,14 @@ static inline int gfs2_is_jdata(const struct gfs2_inode *ip)
return ip->i_diskflags & GFS2_DIF_JDATA;
 }
 
-static inline int gfs2_is_writeback(const struct gfs2_inode *ip)
+static inline bool gfs2_is_ordered(const struct gfs2_sbd *sdp)
 {
-   const struct gfs2_sbd *sdp = GFS2_SB(>i_inode);
-   return (sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK) && 
!gfs2_is_jdata(ip);
+   return sdp->sd_args.ar_data == GFS2_DATA_ORDERED;
 }
 
-static inline int gfs2_is_ordered(const struct gfs2_inode *ip)
+static inline bool gfs2_is_writeback(const struct gfs2_sbd *sdp)
 {
-   const struct gfs2_sbd *sdp = GFS2_SB(>i_inode);
-   return (sdp->sd_args.ar_data == GFS2_DATA_ORDERED) && 
!gfs2_is_jdata(ip);
+   return sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK;
 }
 
 static inline int gfs2_is_dir(const struct gfs2_inode *ip)
diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h
index 20241436126d..1bc9bd444b28 100644
--- a/fs/gfs2/log.h
+++ b/fs/gfs2/log.h
@@ -51,12 +51,11 @@ static inline void gfs2_log_pointers_init(struct gfs2_sbd 
*sdp,
 
 static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
 {
-   struct gfs2_sbd *sdp;
+   struct gfs2_sbd *sdp = GFS2_SB(>i_inode);
 
-   if (!gfs2_is_ordered(ip))
+   if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp))
return;
 
-   sdp = GFS2_SB(>i_inode);
if (!test_bit(GIF_ORDERED, >i_flags)) {
spin_lock(>sd_ordered_lock);
if (!test_and_set_bit(GIF_ORDERED, >i_flags))
-- 
2.17.1



[Cluster-devel] [PATCH] gfs2: Fix iomap buffered write support for journaled files (2)

2018-10-12 Thread Andreas Gruenbacher
It turns out that the fix in commit 6636c3cc56 is bad; the assertion
that the iomap code no longer creates buffer heads is incorrect for
filesystems that set the IOMAP_F_BUFFER_HEAD flag.

Instead, what's happening is that gfs2_iomap_begin_write treats all
files that have the jdata flag set as journaled files, which is
incorrect as long as those files are inline ("stuffed").  We're handling
stuffed files directly via the page cache, which is why we ended up with
pages without buffer heads in gfs2_page_add_databufs.

Fix this by handling stuffed journaled files correctly in
gfs2_iomap_begin_write.

This reverts commit 6636c3cc5690c11631e6366cf9a28fb99c8b25bb.

Signed-off-by: Andreas Gruenbacher 
---
 fs/gfs2/bmap.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 3c159a7f9a9e..84544a4f012d 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -975,10 +975,6 @@ static void gfs2_iomap_journaled_page_done(struct inode 
*inode, loff_t pos,
 {
struct gfs2_inode *ip = GFS2_I(inode);
 
-   if (!page_has_buffers(page)) {
-   create_empty_buffers(page, inode->i_sb->s_blocksize,
-(1 << BH_Dirty)|(1 << BH_Uptodate));
-   }
gfs2_page_add_databufs(ip, page, offset_in_page(pos), copied);
 }
 
@@ -1061,7 +1057,7 @@ static int gfs2_iomap_begin_write(struct inode *inode, 
loff_t pos,
}
}
release_metapath();
-   if (gfs2_is_jdata(ip))
+   if (!gfs2_is_stuffed(ip) && gfs2_is_jdata(ip))
iomap->page_done = gfs2_iomap_journaled_page_done;
return 0;
 
-- 
2.17.1



[Cluster-devel] [GIT PULL] gfs2: another 4.19 fix

2018-10-12 Thread Andreas Gruenbacher
Hi Greg,

as explained in the commit in this pull request, the previous fix I've
sent was bad. Could you please pull this follow-up fix?

Thanks,
Andreas

--

The following changes since commit dc480feb454a975b7ee2c18a2f98fb34e04d3baf:

  gfs2: Fix iomap buffered write support for journaled files
(2018-10-09 18:20:13 +0200)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git
tags/gfs2-4.19.fixes3

for you to fetch changes up to fee5150c484c75c473dc1e2d07cb6151384ef85f:

  gfs2: Fix iomap buffered write support for journaled files (2)
(2018-10-12 17:14:42 +0200)


Andreas Gruenbacher (1):
  gfs2: Fix iomap buffered write support for journaled files (2)

 fs/gfs2/bmap.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)



Re: [Cluster-devel] [PATCH 0/9] gfs2: Minor cleanups and fixes

2018-10-12 Thread Bob Peterson
Hi,

Thanks. This patch set is now pushed to the for-next branch of the linux-gfs2 
tree:

- Original Message -
> Here are some minor cleanups and fixes that resulted from looking into
> the resource group glock sharing patches (mostly updated versions of the
> patches I've previously posted on October 5).  These should be ready to
> go into the next merge window.
> 
> Thanks,
> Andreas
> 
> Andreas Gruenbacher (8):
>   gfs2: Always check the result of gfs2_rbm_from_block
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next=f654683dae0d6c4e02eb7126b14f19fd945c3569
>   gfs2: Clean up out-of-bounds check in gfs2_rbm_from_block
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next=3548fce1645bafbeb2256caaa3635a21bafd1621
>   gfs2: Move rs_{sizehint, rgd_gh} fields into the inode
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next=21f09c4395c95dfaa0598d20d41cb2a669e1967e
>   gfs2: Remove unused RGRP_RSRV_MINBYTES definition
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next=ad8994581815ac08123c7eeceb2ef160a96d186d
>   gfs2: Rename bitmap.bi_{len => bytes}
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next=281b4952d185a3ba0340b412faa47fd745565552
>   gfs2: Fix some minor typos
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next=243fea4df910ca1463a1114321823082b5440991
>   gfs2: Fix marking bitmaps non-full
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next=ec23df2b0cf3e1620f5db77972b7fb735f267eff
>   gfs2: Pass resource group to rgblk_free
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next=0ddeded4ae768882e5c3a5558f77f27e4e445a6a

> Bob Peterson (1):
>   gfs2: Remove unnecessary gfs2_rlist_alloc parameter
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next=c3abc29e54a14953ddb26feeb62dd02d57925e52

Regards,

Bob Peterson
Red Hat File Systems



Re: [Cluster-devel] [PATCH 7/9] gfs2: Fix marking bitmaps non-full

2018-10-12 Thread Steven Whitehouse

Hi,


On 12/10/18 13:06, Bob Peterson wrote:

- Original Message -

Hi,
The series looks good I think. This one though looks like a bug fix and
should probably go to -stable too?

Steve.

I concur. So can I add your reviewed-by before I push?

Bob Peterson


Yes, please do,

Steve.



Re: [Cluster-devel] [PATCH 7/9] gfs2: Fix marking bitmaps non-full

2018-10-12 Thread Bob Peterson
- Original Message -
> Hi,
> The series looks good I think. This one though looks like a bug fix and
> should probably go to -stable too?
> 
> Steve.

I concur. So can I add your reviewed-by before I push?

Bob Peterson



Re: [Cluster-devel] [PATCH 7/9] gfs2: Fix marking bitmaps non-full

2018-10-12 Thread Andreas Gruenbacher
On Fri, 12 Oct 2018 at 11:15, Steven Whitehouse  wrote:
> The series looks good I think. This one though looks like a bug fix and
> should probably go to -stable too?

Yes, that's a good idea. The fix applies all the way back to v4.4 or
even further.

Thanks,
Andreas



Re: [Cluster-devel] [PATCH 7/9] gfs2: Fix marking bitmaps non-full

2018-10-12 Thread Steven Whitehouse

Hi,


On 11/10/18 20:20, Andreas Gruenbacher wrote:

Reservations in gfs can span multiple gfs2_bitmaps (but they won't span
multiple resource groups).  When removing a reservation, we want to
clear the GBF_FULL flags of all involved gfs2_bitmaps, not just that of
the first bitmap.

Signed-off-by: Andreas Gruenbacher 
---
  fs/gfs2/rgrp.c | 13 +++--
  1 file changed, 11 insertions(+), 2 deletions(-)
The series looks good I think. This one though looks like a bug fix and 
should probably go to -stable too?


Steve.



diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index f47c76d9d9d0..7c5904c49a6a 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -641,7 +641,10 @@ static void __rs_deltree(struct gfs2_blkreserv *rs)
RB_CLEAR_NODE(>rs_node);
  
  	if (rs->rs_free) {

-   struct gfs2_bitmap *bi = rbm_bi(>rs_rbm);
+   u64 last_block = gfs2_rbm_to_block(>rs_rbm) +
+rs->rs_free - 1;
+   struct gfs2_rbm last_rbm = { .rgd = rs->rs_rbm.rgd, };
+   struct gfs2_bitmap *start, *last;
  
  		/* return reserved blocks to the rgrp */

BUG_ON(rs->rs_rbm.rgd->rd_reserved < rs->rs_free);
@@ -652,7 +655,13 @@ static void __rs_deltree(struct gfs2_blkreserv *rs)
   it will force the number to be recalculated later. */
rgd->rd_extfail_pt += rs->rs_free;
rs->rs_free = 0;
-   clear_bit(GBF_FULL, >bi_flags);
+   if (gfs2_rbm_from_block(_rbm, last_block))
+   return;
+   start = rbm_bi(>rs_rbm);
+   last = rbm_bi(_rbm);
+   do
+   clear_bit(GBF_FULL, >bi_flags);
+   while (start++ != last);
}
  }