gfs2: silence sparse
Andreas Gruenbacher
maintainercover gfs2: silence sparse
Hello,
this patch queue is based on a patch from Adrian Garcia Casado [*] and fixes the current sparse errors and warnings. Please review.
I have put those patches onto the for-later branch for now [**]; my plan is to move them to for-next once the 7.3 merge window closes.
Thanks,
Andreas
[*] https://lore.kernel.org/gfs2/[email protected]/
[**] https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/log/?h=for-later
Andreas Gruenbacher (6):
gfs2: Avoid ip->i_gl dereferences in gfs2_inode_lookup and
gfs2_create_inode
gfs2: Get to super block from inode in tracepoints
gfs2: Add inode variables
gfs2: Introduce gfs2_inode_glock
gfs2: annotate i_gl with __rcu
gfs2: Silence sparse signedness warning
fs/gfs2/acl.c | 11 ++-- fs/gfs2/aops.c | 17 +++--- fs/gfs2/bmap.c | 89 +++++++++++++++++-------------- fs/gfs2/dentry.c | 6 +-- fs/gfs2/dir.c | 61 ++++++++++++++-------- fs/gfs2/export.c | 7 +-- fs/gfs2/file.c | 72 ++++++++++++++----------- fs/gfs2/glock.c | 4 +- fs/gfs2/glops.c | 3 +- fs/gfs2/incore.h | 7 ++- fs/gfs2/inode.c | 122 ++++++++++++++++++++++++------------------- fs/gfs2/lops.c | 18 +++---- fs/gfs2/meta_io.c | 7 +-- fs/gfs2/ops_fstype.c | 25 +++++---- fs/gfs2/quota.c | 48 +++++++++-------- fs/gfs2/recovery.c | 17 +++--- fs/gfs2/rgrp.c | 4 +- fs/gfs2/super.c | 70 +++++++++++++------------ fs/gfs2/trace_gfs2.h | 6 +-- fs/gfs2/util.c | 8 +-- fs/gfs2/xattr.c | 69 ++++++++++++++---------- 21 files changed, 373 insertions(+), 298 deletions(-)
Signature · 1 line
2.55.0
Andreas Gruenbacher
maintainerPATCH 1/6 gfs2: Avoid ip->i_gl dereferences in gfs2_inode_lookup and gfs2_create_inode
Store the inode glock in a separate variable instead of repeatedly retrieving it as ip->i_gl.
--- fs/gfs2/inode.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
fs/gfs2/inode.c +19 -16
@@ -130,6 +130,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, {struct inode *inode;struct gfs2_inode *ip; +struct gfs2_glock *gl =NULL ;struct gfs2_holder i_gh;int error;
@@ -147,9 +148,10 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,gfs2_setup_inode (inode); error =gfs2_glock_get (sdp, no_addr, &gfs2_inode_glops,CREATE , - &ip->i_gl); + &gl);if (unlikely (error)) goto fail; + ip->i_gl = gl; error =gfs2_glock_get (sdp, no_addr, &gfs2_iopen_glops,CREATE , &io_gl);
@@ -178,14 +180,14 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,* block. We read the inode when instantiating it * after possibly checking the block type. */ - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE , + error =gfs2_glock_nq_init (gl,LM_ST_EXCLUSIVE ,GL_SKIP , &i_gh);if (error) goto fail; error = -ESTALE ;if (no_formal_ino && -gfs2_inode_already_deleted (ip->i_gl, no_formal_ino)) +gfs2_inode_already_deleted (gl, no_formal_ino)) goto fail;if (blktype !=GFS2_BLKST_FREE ) {
@@ -196,20 +198,20 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, } } -set_bit (GLF_INSTANTIATE_NEEDED , &ip->i_gl->gl_flags); +set_bit (GLF_INSTANTIATE_NEEDED , &gl->gl_flags);/* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */ inode_set_atime (inode,1LL << (8 *sizeof (inode_get_atime_sec (inode)) -1 ),0 ); -glock_set_object (ip->i_gl, ip); +glock_set_object (gl, ip);if (type ==DT_UNKNOWN ) {/* Inode glock must be locked already */ error =gfs2_instantiate (&i_gh);if (error) { -glock_clear_object (ip->i_gl, ip); +glock_clear_object (gl, ip); goto fail; } }else {
@@ -240,8 +242,8 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,gfs2_glock_dq_uninit (&ip->i_iopen_gh);if (gfs2_holder_initialized (&i_gh))gfs2_glock_dq_uninit (&i_gh); -if (ip->i_gl) { -gfs2_glock_put (ip->i_gl); +if (gl) { +gfs2_glock_put (gl); ip->i_gl =NULL ; }iget_failed (inode);
@@ -708,7 +710,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,struct inode *inode =NULL ;struct gfs2_inode *dip =GFS2_I (dir), *ip;struct gfs2_sbd *sdp =GFS2_SB (&dip->i_inode); -struct gfs2_glock *io_gl; +struct gfs2_glock *gl =NULL , *io_gl;int error, dealloc_error;u32 aflags =0 ;unsigned blocks =1 ;
@@ -832,9 +834,10 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,gfs2_set_inode_blocks (inode, blocks); - error =gfs2_glock_get (sdp, ip->i_no_addr, &gfs2_inode_glops,CREATE , &ip->i_gl); + error =gfs2_glock_get (sdp, ip->i_no_addr, &gfs2_inode_glops,CREATE , &gl);if (error) goto fail_dealloc_inode; + ip->i_gl = gl; error =gfs2_glock_get (sdp, ip->i_no_addr, &gfs2_iopen_glops,CREATE , &io_gl);if (error)
@@ -854,10 +857,10 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,if (error) goto fail_gunlock2; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,GL_SKIP , &gh); + error =gfs2_glock_nq_init (gl,LM_ST_EXCLUSIVE ,GL_SKIP , &gh);if (error) goto fail_gunlock3; -clear_bit (GLF_INSTANTIATE_NEEDED , &ip->i_gl->gl_flags); +clear_bit (GLF_INSTANTIATE_NEEDED , &gl->gl_flags); error =gfs2_trans_begin (sdp, blocks,0 );if (error)
@@ -870,7 +873,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,init_dinode (dip, ip, symname);gfs2_trans_end (sdp); -glock_set_object (ip->i_gl, ip); +glock_set_object (gl, ip);glock_set_object (io_gl, ip);gfs2_set_iop (inode);
@@ -914,7 +917,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,return error; fail_gunlock4: -glock_clear_object (ip->i_gl, ip); +glock_clear_object (gl, ip);glock_clear_object (io_gl, ip); fail_gunlock3:gfs2_glock_dq_uninit (&ip->i_iopen_gh);
@@ -932,8 +935,8 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,fs_warn (sdp,"%s: %d\n" , __func__, dealloc_error); ip->i_no_addr =0 ; fail_free_inode: -if (ip->i_gl) { -gfs2_glock_put (ip->i_gl); +if (gl) { +gfs2_glock_put (gl); ip->i_gl =NULL ; }gfs2_rs_deltree (&ip->i_res);
Signature · 1 line
2.55.0
Andreas Gruenbacher
maintainerPATCH 2/6 gfs2: Get to super block from inode in tracepoints
In reply to Andreas GruenbacherWhen we have a gfs2 inode, use that to get to the super block instead of going via the glock.
--- fs/gfs2/trace_gfs2.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/gfs2/trace_gfs2.h +3 -3
@@ -457,7 +457,7 @@ TRACE_EVENT(gfs2_bmap, ), TP_fast_assign( - __entry->dev = glock_sbd(ip->i_gl)->sd_vfs->s_dev; + __entry->dev = ip->i_inode.i_sb->s_dev; __entry->lblock = lblock; __entry->pblock =buffer_mapped (bh) ? bh->b_blocknr :0 ; __entry->inum = ip->i_no_addr;
@@ -493,7 +493,7 @@ TRACE_EVENT(gfs2_iomap_start, ), TP_fast_assign( - __entry->dev = glock_sbd(ip->i_gl)->sd_vfs->s_dev; + __entry->dev = ip->i_inode.i_sb->s_dev; __entry->inum = ip->i_no_addr; __entry->pos = pos; __entry->length = length;
@@ -525,7 +525,7 @@ TRACE_EVENT(gfs2_iomap_end, ), TP_fast_assign( - __entry->dev = glock_sbd(ip->i_gl)->sd_vfs->s_dev; + __entry->dev = ip->i_inode.i_sb->s_dev; __entry->inum = ip->i_no_addr; __entry->offset = iomap->offset; __entry->length = iomap->length;
Signature · 1 line
2.55.0
Andreas Gruenbacher
maintainerPATCH 3/6 gfs2: Add inode variables
In reply to Andreas GruenbacherAdd inode variables in a few places to get rid of '&ip->i_inode'. This cleans up the code a little and prepares for the next step of adding an accessor function for ip->i_gl.
--- fs/gfs2/bmap.c | 37 ++++++++++++++++++++----------------- fs/gfs2/dir.c | 4 +++- fs/gfs2/file.c | 5 +++-- fs/gfs2/quota.c | 25 ++++++++++++++----------- fs/gfs2/recovery.c | 5 +++-- 5 files changed, 43 insertions(+), 33 deletions(-)
fs/gfs2/bmap.c +20 -17
@@ -89,6 +89,7 @@ static int gfs2_unstuffer_folio(struct gfs2_inode *ip, struct buffer_head *dibh,static int __gfs2_unstuff_inode (struct gfs2_inode *ip,struct folio *folio) { +struct inode *inode = &ip->i_inode;struct buffer_head *bh, *dibh;struct gfs2_dinode *di;u64 block =0 ;
@@ -99,7 +100,7 @@ static int __gfs2_unstuff_inode(struct gfs2_inode *ip, struct folio *folio)if (error)return error; -if (i_size_read (&ip->i_inode)) { +if (i_size_read (inode)) {/* Get a free block, fill it with the stuffed data, and write it out to disk */
@@ -108,7 +109,7 @@ static int __gfs2_unstuff_inode(struct gfs2_inode *ip, struct folio *folio)if (error) goto out_brelse;if (isdir) { -gfs2_trans_remove_revoke (GFS2_SB (&ip->i_inode), block,1 ); +gfs2_trans_remove_revoke (GFS2_SB (inode), block,1 ); error =gfs2_dir_get_new_buffer (ip, block, &bh);if (error) goto out_brelse;
@@ -128,10 +129,10 @@ static int __gfs2_unstuff_inode(struct gfs2_inode *ip, struct folio *folio) di = (struct gfs2_dinode *)dibh->b_data;gfs2_buffer_clear_tail (dibh,sizeof (struct gfs2_dinode )); -if (i_size_read (&ip->i_inode)) { +if (i_size_read (inode)) { *(__be64 *)(di +1 ) =cpu_to_be64 (block); -gfs2_add_inode_blocks (&ip->i_inode,1 ); - di->di_blocks =cpu_to_be64 (gfs2_get_inode_blocks (&ip->i_inode)); +gfs2_add_inode_blocks (inode,1 ); + di->di_blocks =cpu_to_be64 (gfs2_get_inode_blocks (inode)); } ip->i_height =1 ;
@@ -1488,7 +1489,8 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh, struct buffer_head *bh, __be64 *start, __be64 *end, bool meta, u32 *btotal) { - struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); + struct inode *inode = &ip->i_inode; +struct gfs2_sbd *sdp =GFS2_SB (inode);struct gfs2_rgrpd *rgd;struct gfs2_trans *tr;__be64 *p;
@@ -1546,7 +1548,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh, jblocks_rqsted = rgd->rd_length +RES_DINODE +RES_INDIRECT ; - isize_blks =gfs2_get_inode_blocks (&ip->i_inode); + isize_blks =gfs2_get_inode_blocks (inode);if (isize_blks >atomic_read (&sdp->sd_log_thresh2)) jblocks_rqsted +=atomic_read (&sdp->sd_log_thresh2);
@@ -1597,7 +1599,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,if (bstart) {__gfs2_free_blocks (ip, rgd, bstart, (u32 )blen, meta); (*btotal) += blen; -gfs2_add_inode_blocks (&ip->i_inode, -blen); +gfs2_add_inode_blocks (inode, -blen); } bstart = bn; blen =1 ;
@@ -1605,7 +1607,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,if (bstart) {__gfs2_free_blocks (ip, rgd, bstart, (u32 )blen, meta); (*btotal) += blen; -gfs2_add_inode_blocks (&ip->i_inode, -blen); +gfs2_add_inode_blocks (inode, -blen); } out_unlock:if (!ret && blks_outside_rgrp) {/* If buffer still has non-zero blocks
@@ -1620,7 +1622,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,/* Every transaction boundary, we rewrite the dinode to keep its di_blocks current in case of failure. */ -inode_set_mtime_to_ts (&ip->i_inode,inode_set_ctime_current (&ip->i_inode)); +inode_set_mtime_to_ts (inode,inode_set_ctime_current (inode));gfs2_trans_add_meta (ip->i_gl, dibh);gfs2_dinode_out (ip, dibh->b_data);brelse (dibh);
@@ -1746,7 +1748,8 @@ static inline bool walk_done(struct gfs2_sbd *sdp,*/ static int punch_hole (struct gfs2_inode *ip,u64 offset,u64 length) { -struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode); +struct inode *inode = &ip->i_inode; +struct gfs2_sbd *sdp =GFS2_SB (inode);u64 maxsize = sdp->sd_heightsize[ip->i_height];struct metapath mp = {};struct buffer_head *dibh, *bh;
@@ -1985,9 +1988,8 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)down_write (&ip->i_rw_mutex); }gfs2_statfs_change (sdp,0 , +btotal,0 ); -gfs2_quota_change (ip, -(s64 )btotal, ip->i_inode.i_uid, - ip->i_inode.i_gid); -inode_set_mtime_to_ts (&ip->i_inode,inode_set_ctime_current (&ip->i_inode)); +gfs2_quota_change (ip, -(s64 )btotal, inode->i_uid, inode->i_gid); +inode_set_mtime_to_ts (inode,inode_set_ctime_current (inode));gfs2_trans_add_meta (ip->i_gl, dibh);gfs2_dinode_out (ip, dibh->b_data);up_write (&ip->i_rw_mutex);
@@ -2010,7 +2012,8 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)static int trunc_end (struct gfs2_inode *ip) { -struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode); +struct inode *inode = &ip->i_inode; +struct gfs2_sbd *sdp =GFS2_SB (inode);struct buffer_head *dibh;int error;
@@ -2024,13 +2027,13 @@ static int trunc_end(struct gfs2_inode *ip)if (error) goto out; -if (!i_size_read (&ip->i_inode)) { +if (!i_size_read (inode)) { ip->i_height =0 ; ip->i_goal = ip->i_no_addr;gfs2_buffer_clear_tail (dibh,sizeof (struct gfs2_dinode ));gfs2_ordered_del_inode (ip); } -inode_set_mtime_to_ts (&ip->i_inode,inode_set_ctime_current (&ip->i_inode)); +inode_set_mtime_to_ts (inode,inode_set_ctime_current (inode)); ip->i_diskflags &= ~GFS2_DIF_TRUNC_IN_PROG ;gfs2_trans_add_meta (ip->i_gl, dibh);
fs/gfs2/dir.c +3 -1
@@ -759,10 +759,12 @@ static struct gfs2_dirent *gfs2_dirent_split_alloc(struct inode *inode,static int get_leaf (struct gfs2_inode *dip,u64 leaf_no,struct buffer_head **bhp) { +struct inode *inode = &dip->i_inode; +struct gfs2_sbd *sdp =GFS2_SB (inode);int error; error =gfs2_meta_read (dip->i_gl, leaf_no,DIO_WAIT ,0 , bhp); -if (!error &&gfs2_metatype_check (GFS2_SB (&dip->i_inode), *bhp,GFS2_METATYPE_LF )) { +if (!error &&gfs2_metatype_check (sdp, *bhp,GFS2_METATYPE_LF )) {/* pr_info("block num=%llu\n", leaf_no); */ error = -EIO ; }
fs/gfs2/file.c +3 -2
@@ -812,7 +812,8 @@ static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to, struct gfs2_holder *gh) {struct file *file = iocb->ki_filp; -struct gfs2_inode *ip =GFS2_I (file->f_mapping->host); +struct inode *inode = file->f_mapping->host; +struct gfs2_inode *ip =GFS2_I (inode);size_t prev_count =0 , window_size =0 ;size_t read =0 ;ssize_t ret;
@@ -906,7 +907,7 @@ static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from,if (ret) goto out_uninit;/* Silently fall back to buffered I/O when writing beyond EOF */ -if (iocb->ki_pos +iov_iter_count (from) >i_size_read (&ip->i_inode)) +if (iocb->ki_pos +iov_iter_count (from) >i_size_read (inode)) goto out_unlock; from->nofault = true;
fs/gfs2/quota.c +14 -11
@@ -740,8 +740,8 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)static int gfs2_write_buf_to_page (struct gfs2_sbd *sdp,unsigned long index,unsigned off,void *buf,unsigned bytes) { -struct gfs2_inode *ip =GFS2_I (sdp->sd_quota_inode); -struct inode *inode = &ip->i_inode; +struct inode *inode = sdp->sd_quota_inode; +struct gfs2_inode *ip =GFS2_I (inode);struct address_space *mapping = inode->i_mapping;struct folio *folio;struct buffer_head *bh;
@@ -908,7 +908,8 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda, u64 sync_gen) {struct gfs2_sbd *sdp = (*qda)->qd_sbd; -struct gfs2_inode *ip =GFS2_I (sdp->sd_quota_inode); +struct inode *inode = sdp->sd_quota_inode; +struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_alloc_parms ap = {};unsigned int data_blocks, ind_blocks;struct gfs2_holder *ghs, i_gh;
@@ -927,7 +928,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda,return -ENOMEM ;sort (qda, num_qd,sizeof (struct gfs2_quota_data *), sort_qd,NULL ); -inode_lock (&ip->i_inode); +inode_lock (inode);for (qx =0 ; qx < num_qd; qx++) { error =gfs2_glock_nq_init (qda[qx]->qd_gl,LM_ST_EXCLUSIVE ,GL_NOCACHE , &ghs[qx]);
@@ -991,9 +992,9 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda, out_dq:while (qx--)gfs2_glock_dq_uninit (&ghs[qx]); -inode_unlock (&ip->i_inode); +inode_unlock (inode);kfree (ghs); -gfs2_log_flush (glock_sbd (ip->i_gl), ip->i_gl, +gfs2_log_flush (sdp, ip->i_gl,GFS2_LOG_HEAD_FLUSH_NORMAL |GFS2_LFC_DO_SYNC );if (!error) {for (x =0 ; x < num_qd; x++) {
@@ -1402,7 +1403,8 @@ int gfs2_quota_refresh(struct gfs2_sbd *sdp, struct kqid qid)int gfs2_quota_init (struct gfs2_sbd *sdp) { -struct gfs2_inode *ip =GFS2_I (sdp->sd_qc_inode); +struct inode *inode = sdp->sd_qc_inode; +struct gfs2_inode *ip =GFS2_I (inode);u64 size =i_size_read (sdp->sd_qc_inode);unsigned int blocks = size >> sdp->sd_sb.sb_bsize_shift;unsigned int x, slot =0 ;
@@ -1434,7 +1436,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)if (!extlen) { extlen =32 ; - error =gfs2_get_extent (&ip->i_inode, x, &dblock, &extlen); + error =gfs2_get_extent (inode, x, &dblock, &extlen);if (error) goto fail; }
@@ -1714,7 +1716,8 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid, struct qc_dqblk *fdq) {struct gfs2_sbd *sdp = sb->s_fs_info; -struct gfs2_inode *ip =GFS2_I (sdp->sd_quota_inode); +struct inode *inode = sdp->sd_quota_inode; +struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_quota_data *qd;struct gfs2_holder q_gh, i_gh;unsigned int data_blocks, ind_blocks;
@@ -1741,7 +1744,7 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid,if (error) goto out_put; -inode_lock (&ip->i_inode); +inode_lock (inode); error =gfs2_glock_nq_init (qd->qd_gl,LM_ST_EXCLUSIVE ,0 , &q_gh);if (error) goto out_unlockput;
@@ -1807,7 +1810,7 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid,gfs2_glock_dq_uninit (&q_gh); out_unlockput:gfs2_qa_put (ip); -inode_unlock (&ip->i_inode); +inode_unlock (inode); out_put:qd_put (qd);return error;
fs/gfs2/recovery.c +3 -2
@@ -32,14 +32,15 @@ struct workqueue_struct *gfs2_recovery_wq;int gfs2_replay_read_block (struct gfs2_jdesc *jd,unsigned int blk,struct buffer_head **bh) { -struct gfs2_inode *ip =GFS2_I (jd->jd_inode); +struct inode *inode = jd->jd_inode; +struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_glock *gl = ip->i_gl;u64 dblock;u32 extlen;int error; extlen =32 ; - error =gfs2_get_extent (&ip->i_inode, blk, &dblock, &extlen); + error =gfs2_get_extent (inode, blk, &dblock, &extlen);if (error)return error;if (!dblock) {
Signature · 1 line
2.55.0
Andreas Gruenbacher
maintainerPATCH 4/6 gfs2: Introduce gfs2_inode_glock
In reply to Andreas GruenbacherIntroduce gfs2_inode_glock(inode) for getting from an inode to its inode glock. This obsoletes the local variable 'ip' in several places.
The remaining direct accesses to ip->i_gl are for inode creation and distruction, and will be cleaned up in the next patch.
--- fs/gfs2/acl.c | 11 +++--- fs/gfs2/aops.c | 17 ++++----- fs/gfs2/bmap.c | 48 +++++++++++++++---------- fs/gfs2/dentry.c | 6 ++-- fs/gfs2/dir.c | 57 ++++++++++++++++++------------ fs/gfs2/export.c | 7 ++-- fs/gfs2/file.c | 69 ++++++++++++++++++++---------------- fs/gfs2/glock.c | 4 ++- fs/gfs2/glops.c | 3 +- fs/gfs2/incore.h | 5 ++- fs/gfs2/inode.c | 83 ++++++++++++++++++++++++-------------------- fs/gfs2/lops.c | 18 +++++----- fs/gfs2/meta_io.c | 7 ++-- fs/gfs2/ops_fstype.c | 25 +++++++------ fs/gfs2/quota.c | 29 ++++++++-------- fs/gfs2/recovery.c | 12 +++---- fs/gfs2/rgrp.c | 4 +-- fs/gfs2/super.c | 70 +++++++++++++++++++------------------ fs/gfs2/util.c | 8 ++--- fs/gfs2/xattr.c | 69 +++++++++++++++++++++--------------- 20 files changed, 307 insertions(+), 245 deletions(-)
fs/gfs2/acl.c +6 -5
@@ -59,7 +59,7 @@ static struct posix_acl *__gfs2_get_acl(struct inode *inode, int type)struct posix_acl *gfs2_get_acl (struct inode *inode,int type,bool rcu) { -struct gfs2_inode *ip =GFS2_I (inode); +struct gfs2_glock *gl =gfs2_inode_glock (inode);struct gfs2_holder gh;bool need_unlock = false;struct posix_acl *acl;
@@ -67,8 +67,8 @@ struct posix_acl *gfs2_get_acl(struct inode *inode, int type, bool rcu)if (rcu)return ERR_PTR (-ECHILD ); -if (!gfs2_glock_is_locked_by_me (ip->i_gl)) { -int ret =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED , +if (!gfs2_glock_is_locked_by_me (gl)) { +int ret =gfs2_glock_nq_init (gl,LM_ST_SHARED ,LM_FLAG_ANY , &gh);if (ret)return ERR_PTR (ret);
@@ -106,6 +106,7 @@ int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, struct posix_acl *acl, int type) {struct inode *inode =d_inode (dentry); +struct gfs2_glock *gl =gfs2_inode_glock (inode);struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_holder gh;bool need_unlock = false;
@@ -119,8 +120,8 @@ int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,if (ret)return ret; -if (!gfs2_glock_is_locked_by_me (ip->i_gl)) { - ret =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &gh); +if (!gfs2_glock_is_locked_by_me (gl)) { + ret =gfs2_glock_nq_init (gl,LM_ST_EXCLUSIVE ,0 , &gh);if (ret) goto out; need_unlock = true;
fs/gfs2/aops.c +9 -8
@@ -102,7 +102,7 @@ static int __gfs2_jdata_write_folio(struct folio *folio, struct writeback_control *wbc) {struct inode *inode = folio->mapping->host; -struct gfs2_inode *ip =GFS2_I (inode); +struct gfs2_glock *gl =gfs2_inode_glock (inode);if (folio_test_checked (folio)) {folio_clear_checked (folio);
@@ -111,7 +111,7 @@ static int __gfs2_jdata_write_folio(struct folio *folio, inode->i_sb->s_blocksize, BIT(BH_Dirty)|BIT(BH_Uptodate)); } -gfs2_trans_add_databufs (ip->i_gl, folio,0 ,folio_size (folio)); +gfs2_trans_add_databufs (gl, folio,0 ,folio_size (folio)); }return gfs2_write_jdata_folio (folio, wbc); }
@@ -126,13 +126,13 @@ static int __gfs2_jdata_write_folio(struct folio *folio,int gfs2_jdata_writeback (struct address_space *mapping,struct writeback_control *wbc) {struct inode *inode = mapping->host; -struct gfs2_inode *ip =GFS2_I (inode); +struct gfs2_glock *gl =gfs2_inode_glock (inode);struct gfs2_sbd *sdp =GFS2_SB (mapping->host);struct folio *folio =NULL ;int error;BUG_ON (current->journal_info); -if (gfs2_assert_withdraw (sdp, ip->i_gl->gl_state ==LM_ST_EXCLUSIVE )) +if (gfs2_assert_withdraw (sdp, gl->gl_state ==LM_ST_EXCLUSIVE ))return 0 ;while ((folio =writeback_iter (mapping, wbc, folio, &error))) {
@@ -362,14 +362,14 @@ static int gfs2_write_cache_jdata(struct address_space *mapping,static int gfs2_jdata_writepages (struct address_space *mapping,struct writeback_control *wbc) { -struct gfs2_inode *ip =GFS2_I (mapping->host); +struct gfs2_glock *gl =gfs2_inode_glock (mapping->host);struct gfs2_sbd *sdp =GFS2_SB (mapping->host);int ret; ret =gfs2_write_cache_jdata (mapping, wbc);if (ret ==0 && wbc->sync_mode ==WB_SYNC_ALL ) { -gfs2_log_flush (sdp, ip->i_gl,GFS2_LOG_HEAD_FLUSH_NORMAL | -GFS2_LFC_JDATA_WPAGES ); +gfs2_log_flush (sdp, gl,GFS2_LOG_HEAD_FLUSH_NORMAL | +GFS2_LFC_JDATA_WPAGES ); ret =gfs2_write_cache_jdata (mapping, wbc); }return ret;
@@ -561,12 +561,13 @@ static bool gfs2_jdata_dirty_folio(struct address_space *mapping,static sector_t gfs2_bmap (struct address_space *mapping,sector_t lblock) { +struct gfs2_glock *gl =gfs2_inode_glock (mapping->host);struct gfs2_inode *ip =GFS2_I (mapping->host);struct gfs2_holder i_gh;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 (gl,LM_ST_SHARED ,LM_FLAG_ANY , &i_gh);if (error)return 0 ;
fs/gfs2/bmap.c +29 -19
215 lines not on this page · raw message
fs/gfs2/dentry.c +3 -3
@@ -35,8 +35,8 @@static int gfs2_drevalidate (struct inode *dir,const struct qstr *name,struct dentry *dentry,unsigned int flags) { +struct gfs2_glock *gl =gfs2_inode_glock (dir);struct gfs2_sbd *sdp =GFS2_SB (dir); -struct gfs2_inode *dip =GFS2_I (dir);struct inode *inode;struct gfs2_holder d_gh;struct gfs2_inode *ip =NULL ;
@@ -57,9 +57,9 @@ static int gfs2_drevalidate(struct inode *dir, const struct qstr *name,if (sdp->sd_lockstruct.ls_ops->lm_mount ==NULL )return 1 ; - had_lock = (gfs2_glock_is_locked_by_me (dip->i_gl) !=NULL ); + had_lock = (gfs2_glock_is_locked_by_me (gl) !=NULL );if (!had_lock) { - error =gfs2_glock_nq_init (dip->i_gl,LM_ST_SHARED ,0 , &d_gh); + error =gfs2_glock_nq_init (gl,LM_ST_SHARED ,0 , &d_gh);if (error)return 0 ; }
fs/gfs2/dir.c +35 -22
244 lines not on this page · raw message
fs/gfs2/export.c +4 -3
@@ -87,7 +87,8 @@ static int gfs2_get_name(struct dentry *parent, char *name, {struct inode *dir =d_inode (parent);struct inode *inode =d_inode (child); -struct gfs2_inode *dip, *ip; +struct gfs2_glock *gl; +struct gfs2_inode *ip;struct get_name_filldir gnfd = { .ctx.actor = get_name_filldir, .name = name
@@ -102,14 +103,14 @@ static int gfs2_get_name(struct dentry *parent, char *name,if (!S_ISDIR (dir->i_mode) || !inode)return -EINVAL ; - dip =GFS2_I (dir); + gl =gfs2_inode_glock (dir); ip =GFS2_I (inode); *name =0 ; gnfd.inum.no_addr = ip->i_no_addr; gnfd.inum.no_formal_ino = ip->i_no_formal_ino; - error =gfs2_glock_nq_init (dip->i_gl,LM_ST_SHARED ,0 , &gh); + error =gfs2_glock_nq_init (gl,LM_ST_SHARED ,0 , &gh);if (error)return error;
fs/gfs2/file.c +39 -30
280 lines not on this page · raw message
fs/gfs2/glock.c +3 -1
@@ -891,7 +891,9 @@ static void gfs2_try_to_evict(struct gfs2_glock *gl)/* If the inode was evicted, gl->gl_object will now be NULL. */ ip =gfs2_grab_existing_inode (gl);if (ip) { -gfs2_glock_poke (ip->i_gl); +struct gfs2_glock *gl =gfs2_inode_glock (&ip->i_inode); + +gfs2_glock_poke (gl);iput (&ip->i_inode); } }
fs/gfs2/glops.c +1 -2
@@ -602,8 +602,7 @@ static void freeze_go_callback(struct gfs2_glock *gl, bool remote)static int freeze_go_xmote_bh (struct gfs2_glock *gl) {struct gfs2_sbd *sdp =glock_sbd (gl); -struct gfs2_inode *ip =GFS2_I (sdp->sd_jdesc->jd_inode); -struct gfs2_glock *j_gl = ip->i_gl; +struct gfs2_glock *j_gl =gfs2_inode_glock (sdp->sd_jdesc->jd_inode);struct gfs2_log_header_host head;int error;
fs/gfs2/incore.h +4 -1
@@ -879,5 +879,8 @@ static inline unsigned gfs2_max_stuffed_size(const struct gfs2_inode *ip) return GFS2_SB(&ip->i_inode)->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); } +static inline struct gfs2_glock *gfs2_inode_glock (struct inode *inode) +{ +return GFS2_I (inode)->i_gl; +}#endif /* __INCORE_DOT_H__ */ -
fs/gfs2/inode.c +46 -37
249 lines not on this page · raw message
fs/gfs2/lops.c +8 -10
@@ -775,9 +775,8 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, u32 start, struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_inode *ip = GFS2_I(jd->jd_inode); + struct gfs2_glock *gl = gfs2_inode_glock(jd->jd_inode);struct gfs2_sbd *sdp =GFS2_SB (jd->jd_inode); -struct gfs2_glock *gl = ip->i_gl;unsigned int blks =be32_to_cpu (ld->ld_data1);struct buffer_head *bh_log, *bh_ip;u64 blkno;
@@ -828,17 +827,17 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,static void buf_lo_after_scan (struct gfs2_jdesc *jd,int error,int pass) { -struct gfs2_inode *ip =GFS2_I (jd->jd_inode); +struct gfs2_glock *gl =gfs2_inode_glock (jd->jd_inode);struct gfs2_sbd *sdp =GFS2_SB (jd->jd_inode);if (error) { -gfs2_inode_metasync (ip->i_gl); +gfs2_inode_metasync (gl);return ; }if (pass !=1 )return ; -gfs2_inode_metasync (ip->i_gl); +gfs2_inode_metasync (gl);fs_info (sdp,"jid=%u: Replayed %u of %u blocks\n" , jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
@@ -1000,8 +999,7 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,struct gfs2_log_descriptor *ld, __be64 *ptr, int pass) { - struct gfs2_inode *ip = GFS2_I(jd->jd_inode); -struct gfs2_glock *gl = ip->i_gl; + struct gfs2_glock *gl = gfs2_inode_glock(jd->jd_inode);unsigned int blks =be32_to_cpu (ld->ld_data1);struct buffer_head *bh_log, *bh_ip;u64 blkno;
@@ -1048,18 +1046,18 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,static void databuf_lo_after_scan (struct gfs2_jdesc *jd,int error,int pass) { -struct gfs2_inode *ip =GFS2_I (jd->jd_inode); +struct gfs2_glock *gl =gfs2_inode_glock (jd->jd_inode);struct gfs2_sbd *sdp =GFS2_SB (jd->jd_inode);if (error) { -gfs2_inode_metasync (ip->i_gl); +gfs2_inode_metasync (gl);return ; }if (pass !=1 )return ;/* data sync? */ -gfs2_inode_metasync (ip->i_gl); +gfs2_inode_metasync (gl);fs_info (sdp,"jid=%u: Replayed %u of %u data blocks\n" , jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
fs/gfs2/meta_io.c +4 -3
@@ -402,18 +402,19 @@ static struct buffer_head *gfs2_getjdatabuf(struct gfs2_inode *ip, u64 blkno)void gfs2_journal_wipe (struct gfs2_inode *ip,u64 bstart,u32 blen) { +struct gfs2_glock *gl =gfs2_inode_glock (&ip->i_inode);struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode);struct buffer_head *bh;int ty;/* This can only happen during incomplete inode creation. */ -if (!ip->i_gl) +if (!gl)return ;gfs2_ail1_wipe (sdp, bstart, blen);while (blen) { ty =REMOVE_META ; - bh =gfs2_getbuf (ip->i_gl, bstart,NO_CREATE ); + bh =gfs2_getbuf (gl, bstart,NO_CREATE );if (!bh &&gfs2_is_jdata (ip)) { bh =gfs2_getjdatabuf (ip, bstart); ty =REMOVE_JDATA ;
@@ -447,8 +448,8 @@ void gfs2_journal_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen)int gfs2_meta_buffer (struct gfs2_inode *ip,u32 mtype,u64 num,struct buffer_head **bhp) { +struct gfs2_glock *gl =gfs2_inode_glock (&ip->i_inode);struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode); -struct gfs2_glock *gl = ip->i_gl;struct buffer_head *bh;int ret =0 ;int rahead =0 ;
fs/gfs2/ops_fstype.c +12 -13
@@ -534,7 +534,7 @@ static void gfs2_others_may_mount(struct gfs2_sbd *sdp)static int gfs2_jindex_hold (struct gfs2_sbd *sdp,struct gfs2_holder *ji_gh) { -struct gfs2_inode *dip =GFS2_I (sdp->sd_jindex); +struct gfs2_glock *gl =gfs2_inode_glock (sdp->sd_jindex);struct qstr name;char buf[20 ];struct gfs2_jdesc *jd;
@@ -545,7 +545,7 @@ static 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 (gl,LM_ST_SHARED ,0 , ji_gh);if (error)break ;
@@ -611,7 +611,6 @@ static int init_statfs(struct gfs2_sbd *sdp)struct inode *pn =NULL ;char buf[30 ];struct gfs2_jdesc *jd; -struct gfs2_inode *ip; sdp->sd_statfs_inode =gfs2_lookup_meta (master,"statfs" );if (IS_ERR (sdp->sd_statfs_inode)) {
@@ -656,15 +655,15 @@ static int init_statfs(struct gfs2_sbd *sdp)iput (pn); pn =NULL ; - ip =GFS2_I (sdp->sd_sc_inode); - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,GL_NOPID , - &sdp->sd_sc_gh); + error =gfs2_glock_nq_init (gfs2_inode_glock (sdp->sd_sc_inode), +LM_ST_EXCLUSIVE ,GL_NOPID , &sdp->sd_sc_gh);if (error) {fs_err (sdp,"can't lock local \"sc\" file: %d\n" , error); goto free_local; }/* read in the local statfs buffer - other nodes don't change it. */ - error =gfs2_meta_inode_buffer (ip, &sdp->sd_sc_bh); + error =gfs2_meta_inode_buffer (GFS2_I (sdp->sd_sc_inode), + &sdp->sd_sc_bh);if (error) {fs_err (sdp,"Cannot read in local statfs: %d\n" , error); goto unlock_sd_gh;
@@ -697,7 +696,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) {struct inode *master =d_inode (sdp->sd_master_dir);struct gfs2_holder ji_gh; -struct gfs2_inode *ip; +struct gfs2_glock *gl;int error =0 ;gfs2_holder_mark_uninitialized (&ji_gh);
@@ -751,8 +750,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) goto fail_jindex; } - ip =GFS2_I (sdp->sd_jdesc->jd_inode); - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED , + gl =gfs2_inode_glock (sdp->sd_jdesc->jd_inode); + error =gfs2_glock_nq_init (gl,LM_ST_SHARED ,LM_FLAG_RECOVER |GL_EXACT |GL_NOCACHE |GL_NOPID , &sdp->sd_jinode_gh);
@@ -893,7 +892,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo)struct inode *pn =NULL ;char buf[30 ];int error =0 ; -struct gfs2_inode *ip; +struct gfs2_glock *gl;struct inode *master =d_inode (sdp->sd_master_dir);if (sdp->sd_args.ar_spectator)
@@ -920,8 +919,8 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo)iput (pn); pn =NULL ; - ip =GFS2_I (sdp->sd_qc_inode); - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,GL_NOPID , + gl =gfs2_inode_glock (sdp->sd_qc_inode); + error =gfs2_glock_nq_init (gl,LM_ST_EXCLUSIVE ,GL_NOPID , &sdp->sd_qc_gh);if (error) {fs_err (sdp,"can't lock local \"qc\" file: %d\n" , error);
fs/gfs2/quota.c +15 -14
@@ -408,7 +408,7 @@ static int bh_get(struct gfs2_quota_data *qd) {struct gfs2_sbd *sdp = qd->qd_sbd;struct inode *inode = sdp->sd_qc_inode; -struct gfs2_inode *ip =GFS2_I (inode); +struct gfs2_glock *gl =gfs2_inode_glock (inode);unsigned int block, offset;struct buffer_head *bh =NULL ;struct iomap iomap = { };
@@ -434,7 +434,7 @@ static int bh_get(struct gfs2_quota_data *qd)if (iomap.type !=IOMAP_MAPPED )return error; - error =gfs2_meta_read (ip->i_gl, iomap.addr >> inode->i_blkbits, + error =gfs2_meta_read (gl, iomap.addr >> inode->i_blkbits,DIO_WAIT ,0 , &bh);if (error)return error;
@@ -687,12 +687,12 @@ static int sort_qd(const void *a, const void *b)static void do_qc (struct gfs2_quota_data *qd,s64 change) {struct gfs2_sbd *sdp = qd->qd_sbd; -struct gfs2_inode *ip =GFS2_I (sdp->sd_qc_inode); +struct gfs2_glock *gl =gfs2_inode_glock (sdp->sd_qc_inode);struct gfs2_quota_change *qc = qd->qd_bh_qc;bool needs_put = false;s64 x; -gfs2_trans_add_meta (ip->i_gl, qd->qd_bh); +gfs2_trans_add_meta (gl, qd->qd_bh);/* * The QDF_CHANGE flag indicates that the slot in the quota change file
@@ -741,7 +741,7 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index, unsigned off, void *buf, unsigned bytes) { struct inode *inode = sdp->sd_quota_inode; -struct gfs2_inode *ip =GFS2_I (inode); +struct gfs2_glock *gl =gfs2_inode_glock (inode);struct address_space *mapping = inode->i_mapping;struct folio *folio;struct buffer_head *bh;
@@ -780,7 +780,7 @@ static int gfs2_write_buf_to_page(struct gfs2_sbd *sdp, unsigned long index,set_buffer_uptodate (bh);if (bh_read (bh,REQ_META |REQ_PRIO ) <0 ) goto unlock_out; -gfs2_trans_add_data (ip->i_gl, bh); +gfs2_trans_add_data (gl, bh);/* If we need to write to the next block as well */ if (to_write > (bsize - boff)) {
@@ -909,6 +909,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda, {struct gfs2_sbd *sdp = (*qda)->qd_sbd;struct inode *inode = sdp->sd_quota_inode; +struct gfs2_glock *gl =gfs2_inode_glock (inode);struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_alloc_parms ap = {};unsigned int data_blocks, ind_blocks;
@@ -936,7 +937,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda, goto out_dq; } - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &i_gh); + error =gfs2_glock_nq_init (gl,LM_ST_EXCLUSIVE ,0 , &i_gh);if (error) goto out_dq;
@@ -994,8 +995,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda,gfs2_glock_dq_uninit (&ghs[qx]);inode_unlock (inode);kfree (ghs); -gfs2_log_flush (sdp, ip->i_gl, -GFS2_LOG_HEAD_FLUSH_NORMAL |GFS2_LFC_DO_SYNC ); +gfs2_log_flush (sdp, gl,GFS2_LOG_HEAD_FLUSH_NORMAL |GFS2_LFC_DO_SYNC );if (!error) {for (x =0 ; x < num_qd; x++) { qd = qda[x];
@@ -1039,7 +1039,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh, struct gfs2_holder *q_gh) {struct gfs2_sbd *sdp = qd->qd_sbd; -struct gfs2_inode *ip =GFS2_I (sdp->sd_quota_inode); +struct gfs2_glock *gl =gfs2_inode_glock (sdp->sd_quota_inode);struct gfs2_holder i_gh;int error;
@@ -1063,7 +1063,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,if (error)return error; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,0 , &i_gh); + error =gfs2_glock_nq_init (gl,LM_ST_SHARED ,0 , &i_gh);if (error) goto fail;
@@ -1404,7 +1404,7 @@ int gfs2_quota_refresh(struct gfs2_sbd *sdp, struct kqid qid)int gfs2_quota_init (struct gfs2_sbd *sdp) {struct inode *inode = sdp->sd_qc_inode; -struct gfs2_inode *ip =GFS2_I (inode); +struct gfs2_glock *gl =gfs2_inode_glock (inode);u64 size =i_size_read (sdp->sd_qc_inode);unsigned int blocks = size >> sdp->sd_sb.sb_bsize_shift;unsigned int x, slot =0 ;
@@ -1441,7 +1441,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) goto fail; } error = -EIO ; - bh =gfs2_meta_ra (ip->i_gl, dblock, extlen); + bh =gfs2_meta_ra (gl, dblock, extlen);if (!bh) goto fail;if (gfs2_metatype_check (sdp, bh,GFS2_METATYPE_QC ))
@@ -1717,6 +1717,7 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid, {struct gfs2_sbd *sdp = sb->s_fs_info;struct inode *inode = sdp->sd_quota_inode; +struct gfs2_glock *gl =gfs2_inode_glock (inode);struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_quota_data *qd;struct gfs2_holder q_gh, i_gh;
@@ -1748,7 +1749,7 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid, error =gfs2_glock_nq_init (qd->qd_gl,LM_ST_EXCLUSIVE ,0 , &q_gh);if (error) goto out_unlockput; - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , &i_gh); + error =gfs2_glock_nq_init (gl,LM_ST_EXCLUSIVE ,0 , &i_gh);if (error) goto out_q;
fs/gfs2/recovery.c +5 -7
@@ -33,8 +33,8 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, struct buffer_head **bh) {struct inode *inode = jd->jd_inode; +struct gfs2_glock *gl =gfs2_inode_glock (inode);struct gfs2_inode *ip =GFS2_I (inode); -struct gfs2_glock *gl = ip->i_gl;u64 dblock;u32 extlen;int error;
@@ -307,15 +307,13 @@ static int update_statfs_inode(struct gfs2_jdesc *jd, struct inode *inode) {struct gfs2_sbd *sdp =GFS2_SB (jd->jd_inode); -struct gfs2_inode *ip;struct buffer_head *bh;struct gfs2_statfs_change_host sc;int error =0 ;BUG_ON (!inode); - ip =GFS2_I (inode); - error =gfs2_meta_inode_buffer (ip, &bh); + error =gfs2_meta_inode_buffer (GFS2_I (inode), &bh);if (error) goto out;
@@ -346,7 +344,7 @@ static int update_statfs_inode(struct gfs2_jdesc *jd,mark_buffer_dirty (bh);brelse (bh); -gfs2_inode_metasync (ip->i_gl); +gfs2_inode_metasync (gfs2_inode_glock (inode)); out:return error;
@@ -399,7 +397,7 @@ static void recover_local_statfs(struct gfs2_jdesc *jd,void gfs2_recover_func (struct work_struct *work) { struct gfs2_jdesc *jd = container_of(work, struct gfs2_jdesc, jd_work); -struct gfs2_inode *ip =GFS2_I (jd->jd_inode); +struct gfs2_glock *gl =gfs2_inode_glock (jd->jd_inode);struct gfs2_sbd *sdp =GFS2_SB (jd->jd_inode);struct gfs2_log_header_host head;struct gfs2_holder j_gh, ji_gh;
@@ -441,7 +439,7 @@ void gfs2_recover_func(struct work_struct *work) goto fail; } - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED , + error =gfs2_glock_nq_init (gl,LM_ST_SHARED ,LM_FLAG_RECOVER |GL_NOCACHE , &ji_gh);if (error)
fs/gfs2/rgrp.c +2 -2
@@ -1033,8 +1033,8 @@ static int gfs2_ri_update(struct gfs2_inode *ip)int gfs2_rindex_update (struct gfs2_sbd *sdp) { +struct gfs2_glock *gl =gfs2_inode_glock (sdp->sd_rindex);struct gfs2_inode *ip =GFS2_I (sdp->sd_rindex); -struct gfs2_glock *gl = ip->i_gl;struct gfs2_holder ri_gh;int error =0 ;int unlock_required =0 ;
@@ -2453,7 +2453,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,if (error ==0 ) {struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data; -gfs2_trans_add_meta (ip->i_gl, dibh); +gfs2_trans_add_meta (gfs2_inode_glock (&ip->i_inode), dibh); di->di_goal_meta = di->di_goal_data =cpu_to_be64 (ip->i_goal);brelse (dibh);
fs/gfs2/super.c +37 -33
233 lines not on this page · raw message
fs/gfs2/util.c +4 -4
@@ -55,10 +55,9 @@ int check_journal_clean(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd,int error;struct gfs2_holder j_gh;struct gfs2_log_header_host head; -struct gfs2_inode *ip; +struct gfs2_glock *gl =gfs2_inode_glock (jd->jd_inode); - ip =GFS2_I (jd->jd_inode); - error =gfs2_glock_nq_init (ip->i_gl,LM_ST_SHARED ,LM_FLAG_RECOVER | + error =gfs2_glock_nq_init (gl,LM_ST_SHARED ,LM_FLAG_RECOVER |GL_EXACT |GL_NOCACHE , &j_gh);if (error) {if (verbose)
@@ -333,6 +332,7 @@ void gfs2_consist_i(struct gfs2_sbd *sdp, const char *function,void gfs2_consist_inode_i (struct gfs2_inode *ip,const char *function,char *file,unsigned int line) { +struct gfs2_glock *gl =gfs2_inode_glock (&ip->i_inode);struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode); gfs2_lm(sdp,
@@ -342,7 +342,7 @@ void gfs2_consist_inode_i(struct gfs2_inode *ip, (unsigned long long )ip->i_no_formal_ino, (unsigned long long )ip->i_no_addr, function, file, line); -gfs2_dump_glock (NULL , ip->i_gl,1 ); +gfs2_dump_glock (NULL , gl,1 );gfs2_withdraw (sdp); }
fs/gfs2/xattr.c +41 -28
269 lines not on this page · raw message
Signature · 1 line
2.55.0
Andreas Gruenbacher
maintainerPATCH 5/6 gfs2: annotate i_gl with __rcu
In reply to Andreas Gruenbacherip->i_gl is always set over the lifetime of a gfs2 inode; it is initialized at inode create time and torn down during evict.
However, gfs2_permission() can be called on an inode in non-blocking mode, when the inode may already be undergoing evict. So far, to make that work, we have been using rcu_dereference_check() in gfs2_permission() and rcu_assign_pointer() in gfs2_evict_inode().
However, ip->i_gl wasn't marked as __rcu so far. rcu_dereference_check() and rcu_assign_pointer() expect __rcu pointer arguments, and sparse complains when regular pointers are passed to those functions:
fs/gfs2/super.c:1516:17: error: incompatible types in comparison expression (different address spaces):fs/gfs2/super.c:1516:17: struct gfs2_glock [noderef] __rcu *fs/gfs2/super.c:1516:17: struct gfs2_glock *fs/gfs2/inode.c:1988:14: error: incompatible types in comparison expression (different address spaces):fs/gfs2/inode.c:1988:14: struct gfs2_glock [noderef] __rcu *fs/gfs2/inode.c:1988:14: struct gfs2_glock *
To fix those errors, turn ip->i_gl into a __rcu variable. Use rcu_assign_pointer() to assign to it, and rcu_dereference_protected() to access it when the pointer is known to be valid.
Make sure not to use gfs2_inode_glock() in gfs2_permission().
Based on a patch from Adrian Garcia Casado <[email protected]>.
--- fs/gfs2/incore.h | 4 ++-- fs/gfs2/inode.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
fs/gfs2/incore.h +2 -2
@@ -391,7 +391,7 @@ struct gfs2_inode {u64 i_generation;u64 i_eattr;unsigned long i_flags;/* GIF_... */ -struct gfs2_glock *i_gl; +struct gfs2_glock __rcu *i_gl;struct gfs2_holder i_iopen_gh;struct gfs2_qadata *i_qadata;/* quota allocation data */ struct gfs2_holder i_rgd_gh;
@@ -881,6 +881,6 @@ static inline unsigned gfs2_max_stuffed_size(const struct gfs2_inode *ip)static inline struct gfs2_glock *gfs2_inode_glock (struct inode *inode) { -return GFS2_I (inode)->i_gl; +return rcu_dereference_protected (GFS2_I (inode)->i_gl,1 ); }#endif /* __INCORE_DOT_H__ */
fs/gfs2/inode.c +4 -4
@@ -151,7 +151,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type, &gl);if (unlikely (error)) goto fail; - ip->i_gl = gl; +rcu_assign_pointer (ip->i_gl, gl); error =gfs2_glock_get (sdp, no_addr, &gfs2_iopen_glops,CREATE , &io_gl);
@@ -244,7 +244,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,gfs2_glock_dq_uninit (&i_gh);if (gl) {gfs2_glock_put (gl); - ip->i_gl =NULL ; +rcu_assign_pointer (ip->i_gl,NULL ); }iget_failed (inode);return ERR_PTR (error);
@@ -840,7 +840,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, error =gfs2_glock_get (sdp, ip->i_no_addr, &gfs2_inode_glops,CREATE , &gl);if (error) goto fail_dealloc_inode; - ip->i_gl = gl; +rcu_assign_pointer (ip->i_gl, gl); error =gfs2_glock_get (sdp, ip->i_no_addr, &gfs2_iopen_glops,CREATE , &io_gl);if (error)
@@ -940,7 +940,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, fail_free_inode:if (gl) {gfs2_glock_put (gl); - ip->i_gl =NULL ; +rcu_assign_pointer (ip->i_gl,NULL ); }gfs2_rs_deltree (&ip->i_res);gfs2_qa_put (ip);
Signature · 1 line
2.55.0
Andreas Gruenbacher
maintainerPATCH 6/6 gfs2: Silence sparse signedness warning
In reply to Andreas GruenbacherSilence the following sparse warning:
fs/gfs2/bmap.c:1718:42: warning: unsigned value that used to be signed checked against zero? fs/gfs2/bmap.c:2017:16: signed value source
It's unclear to me what sparse is trying to tell me there, but making the height variables unsigned shuts it up.
--- fs/gfs2/bmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/gfs2/bmap.c +2 -2
@@ -1699,7 +1699,7 @@ enum dealloc_states { };static inline void -metapointer_range (struct metapath *mp,int height, +metapointer_range (struct metapath *mp,unsigned int height,__u16 *start_list,unsigned int start_aligned,__u16 *end_list,unsigned int end_aligned,__be64 **start,__be64 **end)
@@ -1770,7 +1770,7 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)unsigned int strip_h = ip->i_height -1 ;u32 btotal =0 ;int ret, state; -int mp_h;/* metapath buffers are read in to this height */ +unsigned int mp_h;/* metapath buffers are read in to this height */ u64 prev_bnr =0 ;__be64 *start, *end;
Signature · 1 line
2.55.0