Eliminate gh_state
PATCH 1/1 Eliminate gh_state
Hi,
This patch reduces the memory requirements of GFS2 by eliminating the gh_state variable from the gfs2_holder structure. With this patch the state is now held in the upper two bits of the gh_flags. There are new macros to fetch and/or set the new state flags.
I hesitated sending this patch just because of its sheer size. Since gfs2_holder is used almost everywhere, the fix is quite pervasive. Also, I don't know the performance impact of it (I haven't taken the time to study the impact). On the one hand, it could be slower because some functions that used to just fetch the state are now required to do masking and shifting. On the other hand, it could also be faster because the unified flags field means that about one hundred calls with four parameters have been replaced by calls with three parameters.
The good news is that there is no tricky logic here. If the macros are correct, the rest of the code changes are mostly just direct substitutions.
So take it or leave it as you see fit.
Regards,
Bob Peterson
Red Hat GFS
--
fs/gfs2/eattr.c | 19 ++++++++++------ fs/gfs2/glock.c | 39 ++++++++++++++++------------------- fs/gfs2/glock.h | 28 ++++-------------------- fs/gfs2/glops.c | 2 +- fs/gfs2/incore.h | 26 ++++++++++++++++++++++- fs/gfs2/inode.c | 31 ++++++++++++++++----------- fs/gfs2/ops_address.c | 13 +++++++---- fs/gfs2/ops_dentry.c | 3 +- fs/gfs2/ops_export.c | 8 ++++-- fs/gfs2/ops_file.c | 27 ++++++++++++----------- fs/gfs2/ops_fstype.c | 20 ++++++++++-------- fs/gfs2/ops_inode.c | 54 +++++++++++++++++++++++++++++-------------------- fs/gfs2/ops_super.c | 7 +++-- fs/gfs2/quota.c | 16 ++++++++------ fs/gfs2/recovery.c | 9 ++++--- fs/gfs2/rgrp.c | 13 ++++++----- fs/gfs2/super.c | 31 +++++++++++++++------------ fs/gfs2/trans.c | 5 ++- 18 files changed, 196 insertions(+), 155 deletions(-)
fs/gfs2/eattr.c +12 -7
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions
@@ -250,7 +250,8 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,return -EIO ; } - error =gfs2_glock_nq_init (rgd->rd_gl,LM_ST_EXCLUSIVE ,0 , &rg_gh); + error =gfs2_glock_nq_init (rgd->rd_gl,gh_stflag (LM_ST_EXCLUSIVE ), + &rg_gh);if (error)return error;
@@ -411,7 +412,8 @@ int gfs2_ea_list(struct gfs2_inode *ip, struct gfs2_ea_request *er) er->er_data_len =0 ; } - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , &i_gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) | +LM_FLAG_ANY , &i_gh);if (error)return error;
@@ -559,7 +561,8 @@ int gfs2_ea_get(struct gfs2_inode *ip, struct gfs2_ea_request *er) er->er_data_len =0 ; } - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , &i_gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) | +LM_FLAG_ANY , &i_gh);if (error)return error;
@@ -1093,7 +1096,8 @@ int gfs2_ea_set(struct gfs2_inode *ip, struct gfs2_ea_request *er)if (error)return error; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &i_gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ), + &i_gh);if (error)return error;
@@ -1185,7 +1189,8 @@ int gfs2_ea_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er)if (!er->er_name_len || er->er_name_len >GFS2_EA_MAX_NAME_LEN )return -EINVAL ; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &i_gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ), + &i_gh);if (error)return error;
@@ -1429,7 +1434,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip)return -EIO ; } - error =gfs2_glock_nq_init (rgd->rd_gl,LM_ST_EXCLUSIVE ,0 , + error =gfs2_glock_nq_init (rgd->rd_gl,gh_stflag (LM_ST_EXCLUSIVE ), &al->al_rgd_gh);if (error)return error;
fs/gfs2/glock.c +18 -21
@@ -132,19 +132,20 @@ static inline rwlock_t *gl_lock_addr(unsigned int x)* Returns: 1 if the locks are compatible, 0 otherwise */ -static inline int relaxed_state_ok (unsigned int actual,unsigned requested, -int flags) +static inline int relaxed_state_ok (unsigned int actual,struct gfs2_holder *gh) { -if (actual == requested) +if (actual ==get_gh_state (gh))return 1 ; -if (flags &GL_EXACT ) +if (gh->gh_flags &GL_EXACT )return 0 ; -if (actual ==LM_ST_EXCLUSIVE && requested ==LM_ST_SHARED ) +if (actual ==LM_ST_EXCLUSIVE && +get_gh_state (gh) ==LM_ST_SHARED )return 1 ; -if (actual !=LM_ST_UNLOCKED && (flags &LM_FLAG_ANY )) +if (actual !=LM_ST_UNLOCKED && + (get_gh_state (gh) &LM_FLAG_ANY ))return 1 ;return 0 ;
@@ -392,14 +393,13 @@ fail:* */ -void gfs2_holder_init (struct gfs2_glock *gl,unsigned int state,unsigned flags, +void gfs2_holder_init (struct gfs2_glock *gl,unsigned flags,struct gfs2_holder *gh) {INIT_LIST_HEAD (&gh->gh_list); gh->gh_gl = gl; gh->gh_ip = (unsigned long )__builtin_return_address (0 ); gh->gh_owner_pid = current->pid; - gh->gh_state = state; gh->gh_flags = flags; gh->gh_error =0 ; gh->gh_iflags =0 ;
@@ -416,9 +416,8 @@ void gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, unsigned flags,* */ -void gfs2_holder_reinit (unsigned int state,unsigned flags,struct gfs2_holder *gh) +void gfs2_holder_reinit (unsigned flags,struct gfs2_holder *gh) { - gh->gh_state = state; gh->gh_flags = flags; gh->gh_iflags =0 ; gh->gh_ip = (unsigned long )__builtin_return_address (0 );
@@ -504,7 +503,7 @@ static int rq_promote(struct gfs2_holder *gh) {struct gfs2_glock *gl = gh->gh_gl; -if (!relaxed_state_ok (gl->gl_state, gh->gh_state, gh->gh_flags)) { +if (!relaxed_state_ok (gl->gl_state, gh)) {if (list_empty (&gl->gl_holders)) { gl->gl_req_gh = gh;set_bit (GLF_LOCK , &gl->gl_flags);
@@ -520,11 +519,11 @@ static int rq_promote(struct gfs2_holder *gh)set_bit (GLF_LOCK , &gl->gl_flags); }else {struct gfs2_holder *next_gh; -if (gh->gh_state ==LM_ST_EXCLUSIVE ) +if (get_gh_state (gh) ==LM_ST_EXCLUSIVE )return 1 ; next_gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list); -if (next_gh->gh_state ==LM_ST_EXCLUSIVE ) +if (get_gh_state (next_gh) ==LM_ST_EXCLUSIVE )return 1 ; }
@@ -624,7 +623,7 @@ static void gfs2_glmutex_lock(struct gfs2_glock *gl)if (test_and_set_bit (GLF_LOCK , &gl->gl_flags)) {struct gfs2_holder gh; -gfs2_holder_init (gl,0 ,0 , &gh); +gfs2_holder_init (gl,0 , &gh);set_bit (HIF_WAIT , &gh.gh_iflags);list_add_tail (&gh.gh_list, &gl->gl_waiters1);spin_unlock (&gl->gl_spin);
@@ -842,7 +841,7 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) gh->gh_error =GLR_CANCELED ;if (ret &LM_OUT_CANCELED ) goto out; -if (relaxed_state_ok (gl->gl_state, gh->gh_state, gh->gh_flags)) { +if (relaxed_state_ok (gl->gl_state, gh)) {list_add_tail (&gh->gh_list, &gl->gl_holders); gh->gh_error =0 ;set_bit (HIF_HOLDER , &gh->gh_iflags);
@@ -888,7 +887,7 @@ static void gfs2_glock_xmote_th(struct gfs2_glock *gl, struct gfs2_holder *gh) {struct gfs2_sbd *sdp = gl->gl_sbd;int flags = gh ? gh->gh_flags :0 ; -unsigned state = gh ? gh->gh_state : gl->gl_demote_state; +unsigned state = gh ?get_gh_state (gh) : gl->gl_demote_state;const struct gfs2_glock_operations *glops = gl->gl_ops; int lck_flags = flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP | LM_FLAG_ANY |
@@ -1017,8 +1016,7 @@ static int glock_wait_internal(struct gfs2_holder *gh)return gh->gh_error;gfs2_assert_withdraw (sdp,test_bit (HIF_HOLDER , &gh->gh_iflags)); -gfs2_assert_withdraw (sdp,relaxed_state_ok (gl->gl_state, gh->gh_state, - gh->gh_flags)); +gfs2_assert_withdraw (sdp,relaxed_state_ok (gl->gl_state, gh));if (test_bit (HIF_FIRST , &gh->gh_iflags)) {gfs2_assert_warn (sdp,test_bit (GLF_LOCK , &gl->gl_flags));
@@ -1280,14 +1278,14 @@ void gfs2_glock_dq_uninit(struct gfs2_holder *gh)int gfs2_glock_nq_num (struct gfs2_sbd *sdp,u64 number,const struct gfs2_glock_operations *glops, -unsigned int state,int flags,struct gfs2_holder *gh) +unsigned int flags,struct gfs2_holder *gh) {struct gfs2_glock *gl;int error; error =gfs2_glock_get (sdp, number, glops,CREATE , &gl);if (!error) { - error =gfs2_glock_nq_init (gl, state, flags, gh); + error =gfs2_glock_nq_init (gl, flags, gh);gfs2_glock_put (gl); }
@@ -1803,7 +1801,6 @@ static int dump_holder(struct glock_iter *gi, char *str,print_dbg (gi,"(ended)\n" ); }else print_dbg (gi," owner = -1\n" ); -print_dbg (gi," gh_state = %u\n" , gh->gh_state);print_dbg (gi," gh_flags =" );for (x =0 ; x <32 ; x++)if (gh->gh_flags & (1 << x))
fs/gfs2/glock.h +5 -23
@@ -13,22 +13,6 @@#include <linux/sched.h> #include "incore.h" -/* Flags for lock requests; used in gfs2_holder gh_flag field. -From lm_interface.h: -#define LM_FLAG_TRY 0x00000001 -#define LM_FLAG_TRY_1CB 0x00000002 -#define LM_FLAG_NOEXP 0x00000004 -#define LM_FLAG_ANY 0x00000008 -#define LM_FLAG_PRIORITY 0x00000010 */ - -#define GL_ASYNC 0x00000040 -#define GL_EXACT 0x00000080 -#define GL_SKIP 0x00000100 -#define GL_ATIME 0x00000200 -#define GL_NOCACHE 0x00000400 -#define GL_FLOCK 0x00000800 -#define GL_NOCANCEL 0x00001000 -#define GLR_TRYFAILED 13#define GLR_CANCELED 14
@@ -78,10 +62,9 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, const struct gfs2_glock_operations *glops, int create, struct gfs2_glock **glp);int gfs2_glock_put (struct gfs2_glock *gl); -void gfs2_holder_init (struct gfs2_glock *gl,unsigned int state,unsigned flags, +void gfs2_holder_init (struct gfs2_glock *gl,unsigned flags,struct gfs2_holder *gh); -void gfs2_holder_reinit (unsigned int state,unsigned flags, -struct gfs2_holder *gh); +void gfs2_holder_reinit (unsigned flags,struct gfs2_holder *gh);void gfs2_holder_uninit (struct gfs2_holder *gh);int gfs2_glock_nq (struct gfs2_holder *gh);int gfs2_glock_poll (struct gfs2_holder *gh);
@@ -92,7 +75,7 @@ void gfs2_glock_dq_wait(struct gfs2_holder *gh);void gfs2_glock_dq_uninit (struct gfs2_holder *gh);int gfs2_glock_nq_num (struct gfs2_sbd *sdp,u64 number,const struct gfs2_glock_operations *glops, -unsigned int state,int flags,struct gfs2_holder *gh); +unsigned int flags,struct gfs2_holder *gh);int gfs2_glock_nq_m (unsigned int num_gh,struct gfs2_holder *ghs);void gfs2_glock_dq_m (unsigned int num_gh,struct gfs2_holder *ghs);
@@ -108,13 +91,12 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs);* Returns: 0, GLR_*, or errno */ -static inline int gfs2_glock_nq_init (struct gfs2_glock *gl, -unsigned int state,int flags, +static inline int gfs2_glock_nq_init (struct gfs2_glock *gl,int flags,struct gfs2_holder *gh) {int error; -gfs2_holder_init (gl, state, flags, gh); +gfs2_holder_init (gl, flags, gh); error =gfs2_glock_nq (gh);if (error)
fs/gfs2/glops.c +1 -1
@@ -254,7 +254,7 @@ static int inode_go_lock(struct gfs2_holder *gh)if ((ip->i_di.di_flags &GFS2_DIF_TRUNC_IN_PROG ) && (gl->gl_state ==LM_ST_EXCLUSIVE ) && - (gh->gh_state ==LM_ST_EXCLUSIVE )) + (get_gh_state (gh) ==LM_ST_EXCLUSIVE )) error =gfs2_truncatei_resume (ip);return error;
fs/gfs2/incore.h +25 -1
@@ -146,12 +146,36 @@ enum { HIF_WAIT = 10, }; +/* Flags for lock requests; used in gfs2_holder gh_flag field. +From lm_interface.h: +#define LM_FLAG_TRY 0x00000001 +#define LM_FLAG_TRY_1CB 0x00000002 +#define LM_FLAG_NOEXP 0x00000004 +#define LM_FLAG_ANY 0x00000008 +#define LM_FLAG_PRIORITY 0x00000010 */ + +#define GL_ASYNC 0x00000040 +#define GL_EXACT 0x00000080 +#define GL_SKIP 0x00000100 +#define GL_ATIME 0x00000200 +#define GL_NOCACHE 0x00000400 +#define GL_FLOCK 0x00000800 +#define GL_NOCANCEL 0x00001000 + +#define GH_STATEMASK 0xc0000000/* reserve upper 2 bits for state */ +#define GH_STATE_SHIFT 30 + +#define gh_stflag (lm_state) (lm_state << GH_STATE_SHIFT) +#define get_gh_state (gh) ((gh->gh_flags & GH_STATEMASK) >> GH_STATE_SHIFT) +#define set_gh_state (gh, state) \ + gh->gh_flags = (gh->gh_flags & ~GH_STATEMASK || \ + ((state << GH_STATE_SHIFT) & GH_STATEMASK)) +struct gfs2_holder {struct list_head gh_list;struct gfs2_glock *gh_gl;pid_t gh_owner_pid; -unsigned int gh_state;unsigned gh_flags;int gh_error;
fs/gfs2/inode.c +18 -13
@@ -199,7 +199,8 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, goto fail_put;set_bit (GIF_INVALID , &ip->i_flags); - error =gfs2_glock_nq_init (io_gl,LM_ST_SHARED ,GL_EXACT , &ip->i_iopen_gh); + error =gfs2_glock_nq_init (io_gl,gh_stflag (LM_ST_SHARED ) | +GL_EXACT , &ip->i_iopen_gh);if (unlikely (error)) goto fail_iopen; ip->i_iopen_gh.gh_gl->gl_object = ip;
@@ -220,7 +221,9 @@ struct inode *gfs2_inode_lookup(struct super_block *sb,*/ if (type ==DT_UNKNOWN ) {struct gfs2_holder gh; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh); + error =gfs2_glock_nq_init (ip->i_gl, +gh_stflag (LM_ST_EXCLUSIVE ), + &gh);if (unlikely (error)) goto fail_glock;/* Inode is now uptodate */
@@ -365,7 +368,7 @@ int gfs2_dinode_dealloc(struct gfs2_inode *ip) goto out_rindex_relse; } - error =gfs2_glock_nq_init (rgd->rd_gl,LM_ST_EXCLUSIVE ,0 , + error =gfs2_glock_nq_init (rgd->rd_gl,gh_stflag (LM_ST_EXCLUSIVE ), &al->al_rgd_gh);if (error) goto out_rindex_relse;
@@ -493,7 +496,8 @@ struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, }if (gfs2_glock_is_locked_by_me (dip->i_gl) ==0 ) { - error =gfs2_glock_nq_init (dip->i_gl,LM_ST_SHARED ,0 , &d_gh); + error =gfs2_glock_nq_init (dip->i_gl,gh_stflag (LM_ST_SHARED ), + &d_gh);if (error)return ERR_PTR (error); unlock =1 ;
@@ -582,7 +586,8 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino)struct gfs2_inum_range_host ir;int error; - error =gfs2_glock_nq_init (m_ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh); + error =gfs2_glock_nq_init (m_ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ), + &gh);if (error)return error;
@@ -981,7 +986,7 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,if (!name->len || name->len >GFS2_FNAMESIZE )return ERR_PTR (-ENAMETOOLONG ); -gfs2_holder_reinit (LM_ST_EXCLUSIVE ,0 , ghs); +gfs2_holder_reinit (gh_stflag (LM_ST_EXCLUSIVE ), ghs); error =gfs2_glock_nq (ghs);if (error) goto fail;
@@ -999,7 +1004,8 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, goto fail_gunlock; error =gfs2_glock_nq_num (sdp, inum.no_addr, &gfs2_inode_glops, -LM_ST_EXCLUSIVE ,GL_SKIP , ghs +1 ); +gh_stflag (LM_ST_EXCLUSIVE ) |GL_SKIP , + ghs +1 );if (error) goto fail_gunlock;
@@ -1205,7 +1211,7 @@ int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len)unsigned int x;int error; -gfs2_holder_init (ip->i_gl,LM_ST_SHARED ,GL_ATIME , &i_gh); +gfs2_holder_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) |GL_ATIME , &i_gh); error =gfs2_glock_nq_atime (&i_gh);if (error) {gfs2_holder_uninit (&i_gh);
@@ -1259,7 +1265,6 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh)struct gfs2_sbd *sdp = gl->gl_sbd;struct gfs2_inode *ip = gl->gl_object;s64 quantum =gfs2_tune_get (sdp, gt_atime_quantum); -unsigned int state;int flags;int error;struct timespec tv =CURRENT_TIME ;
@@ -1269,7 +1274,6 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh) gfs2_assert_warn(sdp, gl->gl_ops == &gfs2_inode_glops))return -EINVAL ; - state = gh->gh_state; flags = gh->gh_flags; error =gfs2_glock_nq (gh);
@@ -1282,8 +1286,9 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh)if (tv.tv_sec - ip->i_inode.i_atime.tv_sec >= quantum) {gfs2_glock_dq (gh); -gfs2_holder_reinit (LM_ST_EXCLUSIVE , gh->gh_flags & ~LM_FLAG_ANY , - gh); +gfs2_holder_reinit ((gh_stflag (LM_ST_EXCLUSIVE )) | + (gh->gh_flags & + ~(LM_FLAG_ANY |GH_STATEMASK )), gh); error =gfs2_glock_nq (gh);if (error)return error;
@@ -1322,7 +1327,7 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh)in the original state. */ if (gfs2_glock_is_blocking (gl)) {gfs2_glock_dq (gh); -gfs2_holder_reinit (state, flags, gh); +gfs2_holder_reinit (flags, gh);return gfs2_glock_nq (gh); } }
fs/gfs2/ops_address.c +8 -5
@@ -511,7 +511,8 @@ static int gfs2_readpage(struct file *file, struct page *page)struct gfs2_holder gh;int error; -gfs2_holder_init (ip->i_gl,LM_ST_SHARED ,GL_ATIME |LM_FLAG_TRY_1CB , &gh); +gfs2_holder_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) | +GL_ATIME |LM_FLAG_TRY_1CB , &gh); error =gfs2_glock_nq_atime (&gh);if (unlikely (error)) {unlock_page (page);
@@ -592,7 +593,7 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping,struct gfs2_holder gh;int ret; -gfs2_holder_init (ip->i_gl,LM_ST_SHARED ,GL_ATIME , &gh); +gfs2_holder_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) |GL_ATIME , &gh); ret =gfs2_glock_nq_atime (&gh);if (unlikely (ret)) goto out_uninit;
@@ -634,7 +635,8 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,unsigned to = from + len;struct page *page; -gfs2_holder_init (ip->i_gl,LM_ST_EXCLUSIVE ,GL_ATIME , &ip->i_gh); +gfs2_holder_init (ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ) |GL_ATIME , + &ip->i_gh); error =gfs2_glock_nq_atime (&ip->i_gh);if (unlikely (error)) goto out_uninit;
@@ -896,7 +898,8 @@ static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock)sector_t dblock =0 ;int error; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , &i_gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) | +LM_FLAG_ANY , &i_gh);if (error)return 0 ;
@@ -998,7 +1001,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,* unfortunately have the option of only flushing a range like * the VFS does. */ -gfs2_holder_init (ip->i_gl,LM_ST_DEFERRED ,GL_ATIME , &gh); +gfs2_holder_init (ip->i_gl,gh_stflag (LM_ST_DEFERRED ) |GL_ATIME , &gh); rv =gfs2_glock_nq_atime (&gh);if (rv)return rv;
fs/gfs2/ops_dentry.c +2 -1
@@ -56,7 +56,8 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd) had_lock =gfs2_glock_is_locked_by_me (dip->i_gl);if (!had_lock) { - error =gfs2_glock_nq_init (dip->i_gl,LM_ST_SHARED ,0 , &d_gh); + error =gfs2_glock_nq_init (dip->i_gl,gh_stflag (LM_ST_SHARED ), + &d_gh);if (error) goto fail; }
fs/gfs2/ops_export.c +5 -3
@@ -113,7 +113,7 @@ static int gfs2_get_name(struct dentry *parent, char *name, gnfd.inum.no_formal_ino = ip->i_no_formal_ino; gnfd.name = name; - error =gfs2_glock_nq_init (dip->i_gl,LM_ST_SHARED ,0 , &gh); + error =gfs2_glock_nq_init (dip->i_gl,gh_stflag (LM_ST_SHARED ), &gh);if (error)return error;
@@ -177,7 +177,8 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb, } error =gfs2_glock_nq_num (sdp, inum->no_addr, &gfs2_inode_glops, -LM_ST_SHARED ,LM_FLAG_ANY , &i_gh); +gh_stflag (LM_ST_SHARED ) |LM_FLAG_ANY , + &i_gh);if (error)return ERR_PTR (error);
@@ -190,7 +191,8 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb,if (!rgd) goto fail_rindex; - error =gfs2_glock_nq_init (rgd->rd_gl,LM_ST_SHARED ,0 , &rgd_gh); + error =gfs2_glock_nq_init (rgd->rd_gl,gh_stflag (LM_ST_SHARED ), + &rgd_gh);if (error) goto fail_rindex;
fs/gfs2/ops_file.c +14 -13
@@ -59,8 +59,8 @@ static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin)loff_t error;if (origin ==2 ) { - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , - &i_gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) | +LM_FLAG_ANY , &i_gh);if (!error) { error =remote_llseek (file, offset, origin);gfs2_glock_dq_uninit (&i_gh);
@@ -88,7 +88,7 @@ static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir)u64 offset = file->f_pos;int error; -gfs2_holder_init (dip->i_gl,LM_ST_SHARED ,GL_ATIME , &d_gh); +gfs2_holder_init (dip->i_gl,gh_stflag (LM_ST_SHARED ) |GL_ATIME , &d_gh); error =gfs2_glock_nq_atime (&d_gh);if (error) {gfs2_holder_uninit (&d_gh);
@@ -154,7 +154,7 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)int error;u32 fsflags; -gfs2_holder_init (ip->i_gl,LM_ST_SHARED ,GL_ATIME , &gh); +gfs2_holder_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) |GL_ATIME , &gh); error =gfs2_glock_nq_atime (&gh);if (error)return error;
@@ -220,7 +220,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)int error;u32 new_flags, flags; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ), &gh);if (error)return error;
@@ -354,7 +354,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page)struct gfs2_alloc *al;int ret; -gfs2_holder_init (ip->i_gl,LM_ST_EXCLUSIVE ,GL_ATIME , &gh); +gfs2_holder_init (ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ) |GL_ATIME , &gh); ret =gfs2_glock_nq_atime (&gh);if (ret) goto out;
@@ -440,7 +440,7 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma)struct gfs2_holder i_gh;int error; -gfs2_holder_init (ip->i_gl,LM_ST_SHARED ,GL_ATIME , &i_gh); +gfs2_holder_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) |GL_ATIME , &i_gh); error =gfs2_glock_nq_atime (&i_gh);if (error) {gfs2_holder_uninit (&i_gh);
@@ -479,8 +479,8 @@ static int gfs2_open(struct inode *inode, struct file *file) file->private_data = fp;if (S_ISREG (ip->i_inode.i_mode)) { - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_ANY , - &i_gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) | +LM_FLAG_ANY , &i_gh);if (error) goto fail;
@@ -642,26 +642,27 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)int error =0 ; state = (fl->fl_type ==F_WRLCK ) ?LM_ST_EXCLUSIVE :LM_ST_SHARED ; - flags = (IS_SETLKW (cmd) ?0 :LM_FLAG_TRY ) |GL_EXACT |GL_NOCACHE + flags =gh_stflag (state) | + (IS_SETLKW (cmd) ?0 :LM_FLAG_TRY ) |GL_EXACT |GL_NOCACHE |GL_FLOCK ;mutex_lock (&fp->f_fl_mutex); gl = fl_gh->gh_gl;if (gl) { -if (fl_gh->gh_state == state) +if (get_gh_state (fl_gh) == state) goto out;flock_lock_file_wait (file, &(struct file_lock ){.fl_type =F_UNLCK });gfs2_glock_dq_wait (fl_gh); -gfs2_holder_reinit (state, flags, fl_gh); +gfs2_holder_reinit (flags, fl_gh); }else { error =gfs2_glock_get (GFS2_SB (&ip->i_inode), ip->i_no_addr, &gfs2_flock_glops,CREATE , &gl);if (error) goto out; -gfs2_holder_init (gl, state, flags, fl_gh); +gfs2_holder_init (gl, flags, fl_gh);gfs2_glock_put (gl); } error =gfs2_glock_nq (fl_gh);
fs/gfs2/ops_fstype.c +11 -9
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions
@@ -177,7 +177,8 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, error =gfs2_glock_nq_num (sdp,GFS2_MOUNT_LOCK , &gfs2_nondisk_glops, -LM_ST_EXCLUSIVE ,LM_FLAG_NOEXP |GL_NOCACHE , +gh_stflag (LM_ST_EXCLUSIVE ) | +LM_FLAG_NOEXP |GL_NOCACHE , mount_gh);if (error) {fs_err (sdp,"can't acquire mount glock: %d\n" , error);
@@ -186,7 +187,7 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, error =gfs2_glock_nq_num (sdp,GFS2_LIVE_LOCK , &gfs2_nondisk_glops, -LM_ST_SHARED , +gh_stflag (LM_ST_SHARED ) |LM_FLAG_NOEXP |GL_EXACT , &sdp->sd_live_gh);if (error) {
@@ -249,7 +250,7 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) } error =gfs2_glock_nq_num (sdp,GFS2_SB_LOCK , &gfs2_meta_glops, -LM_ST_SHARED ,0 , &sb_gh); +gh_stflag (LM_ST_SHARED ), &sb_gh);if (error) {fs_err (sdp,"can't acquire superblock glock: %d\n" , error);return error;
@@ -414,7 +415,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) error =gfs2_glock_nq_num (sdp, sdp->sd_lockstruct.ls_jid, &gfs2_journal_glops, -LM_ST_EXCLUSIVE ,LM_FLAG_NOEXP , +gh_stflag (LM_ST_EXCLUSIVE ) | +LM_FLAG_NOEXP , &sdp->sd_journal_gh);if (error) {fs_err (sdp,"can't acquire journal glock: %d\n" , error);
@@ -422,7 +424,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) } ip =GFS2_I (sdp->sd_jdesc->jd_inode); - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED , + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) |LM_FLAG_NOEXP |GL_EXACT |GL_NOCACHE , &sdp->sd_jinode_gh);if (error) {
@@ -619,7 +621,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) ip =GFS2_I (sdp->sd_ir_inode); error =gfs2_glock_nq_init (ip->i_gl, -LM_ST_EXCLUSIVE ,0 , +gh_stflag (LM_ST_EXCLUSIVE ), &sdp->sd_ir_gh);if (error) {fs_err (sdp,"can't lock local \"ir\" file: %d\n" , error);
@@ -628,7 +630,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) ip =GFS2_I (sdp->sd_sc_inode); error =gfs2_glock_nq_init (ip->i_gl, -LM_ST_EXCLUSIVE ,0 , +gh_stflag (LM_ST_EXCLUSIVE ), &sdp->sd_sc_gh);if (error) {fs_err (sdp,"can't lock local \"sc\" file: %d\n" , error);
@@ -637,7 +639,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) ip =GFS2_I (sdp->sd_qc_inode); error =gfs2_glock_nq_init (ip->i_gl, -LM_ST_EXCLUSIVE ,0 , +gh_stflag (LM_ST_EXCLUSIVE ), &sdp->sd_qc_gh);if (error) {fs_err (sdp,"can't lock local \"qc\" file: %d\n" , error);
fs/gfs2/ops_inode.c +32 -22
148 lines not on this page · raw message
fs/gfs2/ops_super.c +4 -3
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions
@@ -423,14 +423,15 @@ static void gfs2_delete_inode(struct inode *inode)if (!inode->i_private) goto out; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ), &gh);if (unlikely (error)) {gfs2_glock_dq_uninit (&ip->i_iopen_gh); goto out; }gfs2_glock_dq_wait (&ip->i_iopen_gh); -gfs2_holder_reinit (LM_ST_EXCLUSIVE ,LM_FLAG_TRY_1CB |GL_NOCACHE , &ip->i_iopen_gh); +gfs2_holder_reinit (gh_stflag (LM_ST_EXCLUSIVE ) | +LM_FLAG_TRY_1CB |GL_NOCACHE , &ip->i_iopen_gh); error =gfs2_glock_nq (&ip->i_iopen_gh);if (error) goto out_uninit;
fs/gfs2/quota.c +9 -7
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions
@@ -704,13 +704,14 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)sort (qda, num_qd,sizeof (struct gfs2_quota_data *), sort_qd,NULL );for (qx =0 ; qx < num_qd; qx++) { error =gfs2_glock_nq_init (qda[qx]->qd_gl, -LM_ST_EXCLUSIVE , +gh_stflag (LM_ST_EXCLUSIVE ) |GL_NOCACHE , &ghs[qx]);if (error) goto out; } - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &i_gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ), + &i_gh);if (error) goto out;
@@ -796,7 +797,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,struct gfs2_quota_lvb *qlvb; restart: - error =gfs2_glock_nq_init (qd->qd_gl,LM_ST_SHARED ,0 , q_gh); + error =gfs2_glock_nq_init (qd->qd_gl,gh_stflag (LM_ST_SHARED ), q_gh);if (error)return error;
@@ -806,12 +807,13 @@ restart:loff_t pos;gfs2_glock_dq_uninit (q_gh); error =gfs2_glock_nq_init (qd->qd_gl, -LM_ST_EXCLUSIVE ,GL_NOCACHE , - q_gh); +gh_stflag (LM_ST_EXCLUSIVE ) | +GL_NOCACHE , q_gh);if (error)return error; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,0 , &i_gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_SHARED ), + &i_gh);if (error) goto fail;
fs/gfs2/recovery.c +5 -4
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions
@@ -453,7 +453,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd)/* Aquire the journal lock so we can do recovery */ error =gfs2_glock_nq_num (sdp, jd->jd_jid, &gfs2_journal_glops, -LM_ST_EXCLUSIVE , +gh_stflag (LM_ST_EXCLUSIVE ) |LM_FLAG_NOEXP |LM_FLAG_TRY |GL_NOCACHE , &j_gh);switch (error) {
@@ -468,7 +468,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd) goto fail; }; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED , + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_SHARED ) |LM_FLAG_NOEXP |GL_NOCACHE , &ji_gh);if (error) goto fail_gunlock_j;
@@ -494,7 +494,8 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd)/* Acquire a shared hold on the transaction lock */ - error =gfs2_glock_nq_init (sdp->sd_trans_gl,LM_ST_SHARED , + error =gfs2_glock_nq_init (sdp->sd_trans_gl, +gh_stflag (LM_ST_SHARED ) |LM_FLAG_NOEXP |LM_FLAG_PRIORITY |GL_NOCANCEL |GL_NOCACHE , &t_gh);if (error)
fs/gfs2/rgrp.c +7 -6
@@ -637,7 +637,7 @@ int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh)struct gfs2_glock *gl = ip->i_gl;int error; - error =gfs2_glock_nq_init (gl,LM_ST_SHARED ,0 , ri_gh); + error =gfs2_glock_nq_init (gl,gh_stflag (LM_ST_SHARED ), ri_gh);if (error)return error;
@@ -1086,7 +1086,8 @@ static struct inode *get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) rg_locked =1 ; error =0 ; }else { - error =gfs2_glock_nq_init (rgd->rd_gl,LM_ST_EXCLUSIVE , + error =gfs2_glock_nq_init (rgd->rd_gl, +gh_stflag (LM_ST_EXCLUSIVE ) |LM_FLAG_TRY , &al->al_rgd_gh); }switch (error) {
@@ -1122,8 +1123,9 @@ static struct inode *get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) rg_locked =1 ; error =0 ; }else { - error =gfs2_glock_nq_init (rgd->rd_gl,LM_ST_EXCLUSIVE , flags, - &al->al_rgd_gh); + error =gfs2_glock_nq_init (rgd->rd_gl, +gh_stflag (LM_ST_EXCLUSIVE ) | + flags, &al->al_rgd_gh); }switch (error) {case 0 :
@@ -1717,8 +1719,7 @@ void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state) GFP_NOFS | __GFP_NOFAIL);for (x =0 ; x < rlist->rl_rgrps; x++)gfs2_holder_init (rlist->rl_rgd[x]->rd_gl, - state,0 , - &rlist->rl_ghs[x]); +gh_stflag (state), &rlist->rl_ghs[x]); }/**
fs/gfs2/super.c +17 -14
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions
@@ -366,7 +366,8 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)mutex_lock (&sdp->sd_jindex_mutex);for (;;) { - error =gfs2_glock_nq_init (dip->i_gl,LM_ST_SHARED ,0 , ji_gh); + error =gfs2_glock_nq_init (dip->i_gl,gh_stflag (LM_ST_SHARED ), + ji_gh);if (error)break ;
@@ -545,7 +546,8 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)struct gfs2_log_header_host head;int error; - error =gfs2_glock_nq_init (sdp->sd_trans_gl,LM_ST_SHARED ,0 , &t_gh); + error =gfs2_glock_nq_init (sdp->sd_trans_gl,gh_stflag (LM_ST_SHARED ), + &t_gh);if (error)return error;
@@ -597,8 +599,8 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)gfs2_quota_sync (sdp);gfs2_statfs_sync (sdp); - error =gfs2_glock_nq_init (sdp->sd_trans_gl,LM_ST_SHARED ,GL_NOCACHE , - &t_gh); + error =gfs2_glock_nq_init (sdp->sd_trans_gl,gh_stflag (LM_ST_SHARED ) | +GL_NOCACHE , &t_gh);if (error && !test_bit (SDF_SHUTDOWN , &sdp->sd_flags))return error;
@@ -643,8 +645,8 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp)struct gfs2_holder gh;int error; - error =gfs2_glock_nq_init (m_ip->i_gl,LM_ST_EXCLUSIVE ,GL_NOCACHE , - &gh); + error =gfs2_glock_nq_init (m_ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ) | +GL_NOCACHE , &gh);if (error)return error;
@@ -713,8 +715,8 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp)struct buffer_head *m_bh, *l_bh;int error; - error =gfs2_glock_nq_init (m_ip->i_gl,LM_ST_EXCLUSIVE ,GL_NOCACHE , - &gh); + error =gfs2_glock_nq_init (m_ip->i_gl,gh_stflag (LM_ST_EXCLUSIVE ) | +GL_NOCACHE , &gh);if (error)return error;
@@ -871,7 +873,7 @@ int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc) done =0 ; else if (rgd_next && !error) { error =gfs2_glock_nq_init (rgd_next->rd_gl, -LM_ST_SHARED , +gh_stflag (LM_ST_SHARED ) |GL_ASYNC , gh); rgd_next =gfs2_rgrpd_get_next (rgd_next);
@@ -932,7 +934,8 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, goto out; } ip =GFS2_I (jd->jd_inode); - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,0 , &lfcc->gh); + error =gfs2_glock_nq_init (ip->i_gl,gh_stflag (LM_ST_SHARED ), + &lfcc->gh);if (error) {kfree (lfcc); goto out;
@@ -940,9 +943,9 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,list_add (&lfcc->list, &list); } - error =gfs2_glock_nq_init (sdp->sd_trans_gl,LM_ST_DEFERRED , -LM_FLAG_PRIORITY |GL_NOCACHE , - t_gh); + error =gfs2_glock_nq_init (sdp->sd_trans_gl,gh_stflag (LM_ST_DEFERRED ) | +LM_FLAG_PRIORITY |GL_NOCACHE , + t_gh);list_for_each_entry (jd, &sdp->sd_jindex_list, jd_list) { error =gfs2_jdesc_check (jd);
fs/gfs2/trans.c +3 -2
@@ -1,6 +1,6 @@/* * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. -* Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. +* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions
@@ -49,7 +49,8 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks, sizeof(u64));INIT_LIST_HEAD (&tr->tr_list_buf); -gfs2_holder_init (sdp->sd_trans_gl,LM_ST_SHARED ,0 , &tr->tr_t_gh); +gfs2_holder_init (sdp->sd_trans_gl,gh_stflag (LM_ST_SHARED ), + &tr->tr_t_gh); error =gfs2_glock_nq (&tr->tr_t_gh);if (error)