* [Cluster-devel] [GFS2 PATCH] GFS2: Lock i_mutex and use a local gfs2_holder for fallocate
[not found] <263745248.18138233.1391701350314.JavaMail.root@redhat.com>
@ 2014-02-06 15:43 ` Bob Peterson
2014-02-06 17:34 ` Steven Whitehouse
0 siblings, 1 reply; 2+ messages in thread
From: Bob Peterson @ 2014-02-06 15:43 UTC (permalink / raw)
To: cluster-devel.redhat.com
Hi,
This patch causes GFS2 to lock the i_mutex during fallocate. It
also switches from using a dinode's inode glock to using a local
holder like the other GFS2 i_operations.
Regards,
Bob Peterson
Red Hat File Systems
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index efc078f..6c79408 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -811,6 +811,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1);
loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
loff_t max_chunk_size = UINT_MAX & bsize_mask;
+ struct gfs2_holder gh;
+
next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
/* We only support the FALLOC_FL_KEEP_SIZE mode */
@@ -831,8 +833,10 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
if (error)
return error;
- gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh);
- error = gfs2_glock_nq(&ip->i_gh);
+ mutex_lock(&inode->i_mutex);
+
+ gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
+ error = gfs2_glock_nq(&gh);
if (unlikely(error))
goto out_uninit;
@@ -900,9 +904,10 @@ out_trans_fail:
out_qunlock:
gfs2_quota_unlock(ip);
out_unlock:
- gfs2_glock_dq(&ip->i_gh);
+ gfs2_glock_dq(&gh);
out_uninit:
- gfs2_holder_uninit(&ip->i_gh);
+ gfs2_holder_uninit(&gh);
+ mutex_unlock(&inode->i_mutex);
return error;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Cluster-devel] [GFS2 PATCH] GFS2: Lock i_mutex and use a local gfs2_holder for fallocate
2014-02-06 15:43 ` [Cluster-devel] [GFS2 PATCH] GFS2: Lock i_mutex and use a local gfs2_holder for fallocate Bob Peterson
@ 2014-02-06 17:34 ` Steven Whitehouse
0 siblings, 0 replies; 2+ messages in thread
From: Steven Whitehouse @ 2014-02-06 17:34 UTC (permalink / raw)
To: cluster-devel.redhat.com
Hi,
Now in the -nmw git tree. Thanks,
Steve.
On Thu, 2014-02-06 at 10:43 -0500, Bob Peterson wrote:
> Hi,
>
> This patch causes GFS2 to lock the i_mutex during fallocate. It
> also switches from using a dinode's inode glock to using a local
> holder like the other GFS2 i_operations.
>
> Regards,
>
> Bob Peterson
> Red Hat File Systems
>
> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
> ---
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index efc078f..6c79408 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -811,6 +811,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
> loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1);
> loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
> loff_t max_chunk_size = UINT_MAX & bsize_mask;
> + struct gfs2_holder gh;
> +
> next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
>
> /* We only support the FALLOC_FL_KEEP_SIZE mode */
> @@ -831,8 +833,10 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
> if (error)
> return error;
>
> - gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh);
> - error = gfs2_glock_nq(&ip->i_gh);
> + mutex_lock(&inode->i_mutex);
> +
> + gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
> + error = gfs2_glock_nq(&gh);
> if (unlikely(error))
> goto out_uninit;
>
> @@ -900,9 +904,10 @@ out_trans_fail:
> out_qunlock:
> gfs2_quota_unlock(ip);
> out_unlock:
> - gfs2_glock_dq(&ip->i_gh);
> + gfs2_glock_dq(&gh);
> out_uninit:
> - gfs2_holder_uninit(&ip->i_gh);
> + gfs2_holder_uninit(&gh);
> + mutex_unlock(&inode->i_mutex);
> return error;
> }
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-06 17:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <263745248.18138233.1391701350314.JavaMail.root@redhat.com>
2014-02-06 15:43 ` [Cluster-devel] [GFS2 PATCH] GFS2: Lock i_mutex and use a local gfs2_holder for fallocate Bob Peterson
2014-02-06 17:34 ` Steven Whitehouse
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.