cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [GFS2 PATCH] GFS2: Check rs_free with rd_rsspin protection
       [not found] <323041035.7048186.1467820249716.JavaMail.zimbra@redhat.com>
@ 2016-07-06 15:52 ` Bob Peterson
  2016-07-06 16:01   ` Steven Whitehouse
  0 siblings, 1 reply; 2+ messages in thread
From: Bob Peterson @ 2016-07-06 15:52 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

For the last process to close a file opened for write, function
gfs2_rsqa_delete was deleting the file's inode's block reservation
out of the rgrp reservations tree. Then it was checking to make sure
rs_free was 0, but it was performing the check outside the protection
of rd_rsspin spin_lock. The rd_rsspin spin_lock protection is needed
to prevent a race between the process freeing the reservation and
another who is allocating a new set of blocks inside the same rgrp
for the same inode, thus changing its value.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>

Regards,

Bob Peterson
Red Hat File Systems
---
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index fba38ca..86ccc015 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -658,6 +658,7 @@ void gfs2_rs_deltree(struct gfs2_blkreserv *rs)
 	if (rgd) {
 		spin_lock(&rgd->rd_rsspin);
 		__rs_deltree(rs);
+		BUG_ON(rs->rs_free);
 		spin_unlock(&rgd->rd_rsspin);
 	}
 }
@@ -671,10 +672,8 @@ void gfs2_rs_deltree(struct gfs2_blkreserv *rs)
 void gfs2_rsqa_delete(struct gfs2_inode *ip, atomic_t *wcount)
 {
 	down_write(&ip->i_rw_mutex);
-	if ((wcount == NULL) || (atomic_read(wcount) <= 1)) {
+	if ((wcount == NULL) || (atomic_read(wcount) <= 1))
 		gfs2_rs_deltree(&ip->i_res);
-		BUG_ON(ip->i_res.rs_free);
-	}
 	up_write(&ip->i_rw_mutex);
 	gfs2_qa_delete(ip, wcount);
 }



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

* [Cluster-devel] [GFS2 PATCH] GFS2: Check rs_free with rd_rsspin protection
  2016-07-06 15:52 ` [Cluster-devel] [GFS2 PATCH] GFS2: Check rs_free with rd_rsspin protection Bob Peterson
@ 2016-07-06 16:01   ` Steven Whitehouse
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Whitehouse @ 2016-07-06 16:01 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

Acked-by: Steven Whitehouse <swhiteho@redhat.com>

Steve.

On 06/07/16 16:52, Bob Peterson wrote:
> Hi,
>
> For the last process to close a file opened for write, function
> gfs2_rsqa_delete was deleting the file's inode's block reservation
> out of the rgrp reservations tree. Then it was checking to make sure
> rs_free was 0, but it was performing the check outside the protection
> of rd_rsspin spin_lock. The rd_rsspin spin_lock protection is needed
> to prevent a race between the process freeing the reservation and
> another who is allocating a new set of blocks inside the same rgrp
> for the same inode, thus changing its value.
>
> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
>
> Regards,
>
> Bob Peterson
> Red Hat File Systems
> ---
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index fba38ca..86ccc015 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -658,6 +658,7 @@ void gfs2_rs_deltree(struct gfs2_blkreserv *rs)
>   	if (rgd) {
>   		spin_lock(&rgd->rd_rsspin);
>   		__rs_deltree(rs);
> +		BUG_ON(rs->rs_free);
>   		spin_unlock(&rgd->rd_rsspin);
>   	}
>   }
> @@ -671,10 +672,8 @@ void gfs2_rs_deltree(struct gfs2_blkreserv *rs)
>   void gfs2_rsqa_delete(struct gfs2_inode *ip, atomic_t *wcount)
>   {
>   	down_write(&ip->i_rw_mutex);
> -	if ((wcount == NULL) || (atomic_read(wcount) <= 1)) {
> +	if ((wcount == NULL) || (atomic_read(wcount) <= 1))
>   		gfs2_rs_deltree(&ip->i_res);
> -		BUG_ON(ip->i_res.rs_free);
> -	}
>   	up_write(&ip->i_rw_mutex);
>   	gfs2_qa_delete(ip, wcount);
>   }
>



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

end of thread, other threads:[~2016-07-06 16:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <323041035.7048186.1467820249716.JavaMail.zimbra@redhat.com>
2016-07-06 15:52 ` [Cluster-devel] [GFS2 PATCH] GFS2: Check rs_free with rd_rsspin protection Bob Peterson
2016-07-06 16:01   ` Steven Whitehouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).