Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 89522
b: refs/heads/master
c: 7afd88d
h: refs/heads/master
v: v3
  • Loading branch information
Steven Whitehouse committed Mar 31, 2008
1 parent 8d851c0 commit 83f179e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 60b779cfc1fa52034a996ee12a23b62d32e86000
refs/heads/master: 7afd88d9166a752b52517648bcbe923e05d393fc
13 changes: 6 additions & 7 deletions trunk/fs/gfs2/glock.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,23 @@
#define GLR_TRYFAILED 13
#define GLR_CANCELED 14

static inline int gfs2_glock_is_locked_by_me(struct gfs2_glock *gl)
static inline struct gfs2_holder *gfs2_glock_is_locked_by_me(struct gfs2_glock *gl)
{
struct gfs2_holder *gh;
int locked = 0;
struct pid *pid;

/* Look in glock's list of holders for one with current task as owner */
spin_lock(&gl->gl_spin);
pid = task_pid(current);
list_for_each_entry(gh, &gl->gl_holders, gh_list) {
if (gh->gh_owner_pid == pid) {
locked = 1;
break;
}
if (gh->gh_owner_pid == pid)
goto out;
}
gh = NULL;
out:
spin_unlock(&gl->gl_spin);

return locked;
return gh;
}

static inline int gfs2_glock_is_held_excl(struct gfs2_glock *gl)
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
return dir;
}

if (gfs2_glock_is_locked_by_me(dip->i_gl) == 0) {
if (gfs2_glock_is_locked_by_me(dip->i_gl) == NULL) {
error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
if (error)
return ERR_PTR(error);
Expand Down
27 changes: 15 additions & 12 deletions trunk/fs/gfs2/ops_address.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,23 +508,26 @@ static int __gfs2_readpage(void *file, struct page *page)
static int gfs2_readpage(struct file *file, struct page *page)
{
struct gfs2_inode *ip = GFS2_I(page->mapping->host);
struct gfs2_holder gh;
struct gfs2_holder *gh;
int error;

gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|LM_FLAG_TRY_1CB, &gh);
error = gfs2_glock_nq_atime(&gh);
if (unlikely(error)) {
gh = gfs2_glock_is_locked_by_me(ip->i_gl);
if (!gh) {
gh = kmalloc(sizeof(struct gfs2_holder), GFP_NOFS);
if (!gh)
return -ENOBUFS;
gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, gh);
unlock_page(page);
goto out;
error = gfs2_glock_nq_atime(gh);
if (likely(error != 0))
goto out;
return AOP_TRUNCATED_PAGE;
}
error = __gfs2_readpage(file, page);
gfs2_glock_dq(&gh);
gfs2_glock_dq(gh);
out:
gfs2_holder_uninit(&gh);
if (error == GLR_TRYFAILED) {
yield();
return AOP_TRUNCATED_PAGE;
}
gfs2_holder_uninit(gh);
kfree(gh);
return error;
}

Expand Down Expand Up @@ -826,7 +829,7 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
unsigned int to = from + len;
int ret;

BUG_ON(gfs2_glock_is_locked_by_me(ip->i_gl) == 0);
BUG_ON(gfs2_glock_is_locked_by_me(ip->i_gl) == NULL);

ret = gfs2_meta_inode_buffer(ip, &dibh);
if (unlikely(ret)) {
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/gfs2/ops_dentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
struct gfs2_holder d_gh;
struct gfs2_inode *ip = NULL;
int error;
int had_lock=0;
int had_lock = 0;

if (inode) {
if (is_bad_inode(inode))
Expand All @@ -54,7 +54,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
if (sdp->sd_args.ar_localcaching)
goto valid;

had_lock = gfs2_glock_is_locked_by_me(dip->i_gl);
had_lock = (gfs2_glock_is_locked_by_me(dip->i_gl) != NULL);
if (!had_lock) {
error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
if (error)
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/gfs2/ops_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
int error;
int unlock = 0;

if (gfs2_glock_is_locked_by_me(ip->i_gl) == 0) {
if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) {
error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
if (error)
return error;
Expand Down Expand Up @@ -1065,7 +1065,7 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
int error;
int unlock = 0;

if (gfs2_glock_is_locked_by_me(ip->i_gl) == 0) {
if (gfs2_glock_is_locked_by_me(ip->i_gl) == NULL) {
error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
if (error)
return error;
Expand Down

0 comments on commit 83f179e

Please sign in to comment.