GFS2: Pre-pull patch posting (merge window)
cover GFS2: Pre-pull patch posting (merge window)
Hi,
We've got 18 patches for this merge window, none of which are very major.
1. Andreas Gruenbacher contributed several patches to clean up the gfs2 block allocator to prepare for future performance enhancements.
2. Andy Price contributed a patch to fix a use-after-free problem.
3. I contributed some patches that fix gfs2's broken rgrplvb mount option.
4. I contributed some cleanup patches and error message improvements.
5. Steve Whitehouse and Abhi Das sent a patch to enable getlabel support.
6. Tim Smith contributed a patch to flush the glock delete workqueue at exit.
I'm planning to send a pull request for this set in a few hours.
Regards,
Bob Peterson
---
Andreas Gruenbacher (8):
gfs2: Always check the result of gfs2_rbm_from_block
gfs2: Clean up out-of-bounds check in gfs2_rbm_from_block
gfs2: Move rs_{sizehint, rgd_gh} fields into the inode
gfs2: Remove unused RGRP_RSRV_MINBYTES definition
gfs2: Rename bitmap.bi_{len => bytes}
gfs2: Fix some minor typos
gfs2: Fix marking bitmaps non-full
gfs2: Pass resource group to rgblk_free
Andrew Price (1):
gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd
Bob Peterson (7):
gfs2: improve debug information when lvb mismatches are found
gfs2: Don't set GFS2_RDF_UPTODATE when the lvb is updated
gfs2: slow the deluge of io error messages
gfs2: Use fs_* functions instead of pr_* function where we can
gfs2: Remove unnecessary gfs2_rlist_alloc parameter
gfs2: write revokes should traverse sd_ail1_list in reverse
gfs2: Fix minor typo: couln't versus couldn't.
Steve Whitehouse (1):
gfs2: getlabel support
Tim Smith (1):
GFS2: Flush the GFS2 delete workqueue before stopping the kernel
threads
fs/gfs2/bmap.c | 4 +- fs/gfs2/dir.c | 28 +++--- fs/gfs2/file.c | 18 +++- fs/gfs2/glock.c | 17 ++-- fs/gfs2/incore.h | 9 +- fs/gfs2/lock_dlm.c | 10 +-- fs/gfs2/log.c | 11 ++- fs/gfs2/lops.c | 2 +- fs/gfs2/main.c | 2 + fs/gfs2/ops_fstype.c | 2 +- fs/gfs2/quota.c | 2 +- fs/gfs2/rgrp.c | 201 +++++++++++++++++++++++++------------------ fs/gfs2/rgrp.h | 11 +-- fs/gfs2/super.c | 4 +- fs/gfs2/trans.c | 15 ++-- fs/gfs2/util.c | 16 ++-- fs/gfs2/util.h | 2 +- fs/gfs2/xattr.c | 18 ++-- 18 files changed, 218 insertions(+), 154 deletions(-)
Signature · 1 line
2.17.2
PATCH 1/18 gfs2: improve debug information when lvb mismatches are found
Before this patch, gfs2_rgrp_bh_get would check for lvb mismatches, but it wouldn't tell you what was actually wrong. This patch adds more information to help us debug it. It also makes rgrp consistency checks dump any bad rgrps, and the rgrp dump code dump any lvbs as well as the rgrp itself.
--- fs/gfs2/rgrp.c | 41 ++++++++++++++++++++++++++++++++++++----- fs/gfs2/util.c | 3 +++ 2 files changed, 39 insertions(+), 5 deletions(-)
fs/gfs2/rgrp.c +36 -5
@@ -1103,12 +1103,35 @@ static int gfs2_rgrp_lvb_valid(struct gfs2_rgrpd *rgd) {struct gfs2_rgrp_lvb *rgl = rgd->rd_rgl;struct gfs2_rgrp *str = (struct gfs2_rgrp *)rgd->rd_bits[0 ].bi_bh->b_data; +int valid =1 ; -if (rgl->rl_flags != str->rg_flags || rgl->rl_free != str->rg_free || - rgl->rl_dinodes != str->rg_dinodes || - rgl->rl_igeneration != str->rg_igeneration) -return 0 ; -return 1 ; +if (rgl->rl_flags != str->rg_flags) { +printk (KERN_WARNING "GFS2: rgd: %llu lvb flag mismatch %u/%u" , + (unsigned long long )rgd->rd_addr, +be32_to_cpu (rgl->rl_flags),be32_to_cpu (str->rg_flags)); + valid =0 ; + } +if (rgl->rl_free != str->rg_free) { +printk (KERN_WARNING "GFS2: rgd: %llu lvb free mismatch %u/%u" , + (unsigned long long )rgd->rd_addr, +be32_to_cpu (rgl->rl_free),be32_to_cpu (str->rg_free)); + valid =0 ; + } +if (rgl->rl_dinodes != str->rg_dinodes) { +printk (KERN_WARNING "GFS2: rgd: %llu lvb dinode mismatch %u/%u" , + (unsigned long long )rgd->rd_addr, +be32_to_cpu (rgl->rl_dinodes), +be32_to_cpu (str->rg_dinodes)); + valid =0 ; + } +if (rgl->rl_igeneration != str->rg_igeneration) { +printk (KERN_WARNING "GFS2: rgd: %llu lvb igen mismatch " +"%llu/%llu" , (unsigned long long )rgd->rd_addr, + (unsigned long long )be64_to_cpu (rgl->rl_igeneration), + (unsigned long long )be64_to_cpu (str->rg_igeneration)); + valid =0 ; + } +return valid; }static u32 count_unlinked (struct gfs2_rgrpd *rgd)
@@ -2244,6 +2267,14 @@ void gfs2_rgrp_dump(struct seq_file *seq, const struct gfs2_glock *gl) (unsigned long long )rgd->rd_addr, rgd->rd_flags, rgd->rd_free, rgd->rd_free_clone, rgd->rd_dinodes, rgd->rd_reserved, rgd->rd_extfail_pt); +if (rgd->rd_sbd->sd_args.ar_rgrplvb) { +struct gfs2_rgrp_lvb *rgl = rgd->rd_rgl; + +gfs2_print_dbg (seq," L: f:%02x b:%u i:%u\n" , +be32_to_cpu (rgl->rl_flags), +be32_to_cpu (rgl->rl_free), +be32_to_cpu (rgl->rl_dinodes)); + }spin_lock (&rgd->rd_rsspin);for (n =rb_first (&rgd->rd_rstree); n; n =rb_next (&trs->rs_node)) { trs = rb_entry(n, struct gfs2_blkreserv, rs_node);
fs/gfs2/util.c +3 -0
@@ -19,6 +19,7 @@#include "gfs2.h" #include "incore.h" #include "glock.h" +#include "rgrp.h" #include "util.h" struct kmem_cache *gfs2_glock_cachep__read_mostly ;
@@ -181,6 +182,8 @@ int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide, {struct gfs2_sbd *sdp = rgd->rd_sbd;int rv; + +gfs2_rgrp_dump (NULL , rgd->rd_gl); rv =gfs2_lm_withdraw (sdp,"fatal: filesystem consistency error\n" " RG = %llu\n"
Signature · 1 line
2.17.2
PATCH 2/18 gfs2: Don't set GFS2_RDF_UPTODATE when the lvb is updated
In reply to Bob PetersonThe GFS2_RDF_UPTODATE flag in the rgrp is used to determine when a rgrp buffer is valid. It's cleared when the glock is invalidated, signifying that the buffer data is now invalid. But before this patch, function update_rgrp_lvb was setting the flag when it determined it had a valid lvb. But that's an invalid assumption:
just because you have a valid lvb doesn't mean you have valid buffers. After all, another node may have made the lvb valid, and this node just fetched it from the glock via dlm.
Consider this scenario:
1. The file system is mounted with RGRPLVB option.
2. In gfs2_inplace_reserve it locks the rgrp glock EX, but thanks to GL_SKIP, it skips the gfs2_rgrp_bh_get.
3. Since loops == 0 and the allocation target (ap->target) is bigger than the largest known chunk of blocks in the rgrp (rs->rs_rbm.rgd->rd_extfail_pt) it skips that rgrp and bypasses the call to gfs2_rgrp_bh_get there as well.
4. update_rgrp_lvb sees the lvb MAGIC number is valid, so bypasses gfs2_rgrp_bh_get, but it still sets sets GFS2_RDF_UPTODATE due to this invalid assumption.
5. The next time update_rgrp_lvb is called, it sees the bit is set and just returns 0, assuming both the lvb and rgrp are both uptodate. But since this is a smaller allocation, or space has been freed by another node, thus adjusting the lvb values, it decides to use the rgrp for allocations, with invalid rd_free due to the fact it was never updated.
This patch changes update_rgrp_lvb so it doesn't set the UPTODATE flag anymore. That way, it has no choice but to fetch the latest values.
--- fs/gfs2/rgrp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/rgrp.c +1 -1
@@ -1249,7 +1249,7 @@ static int update_rgrp_lvb(struct gfs2_rgrpd *rgd) rl_flags =be32_to_cpu (rgd->rd_rgl->rl_flags); rl_flags &= ~GFS2_RDF_MASK ; rgd->rd_flags &=GFS2_RDF_MASK ; - rgd->rd_flags |= (rl_flags |GFS2_RDF_UPTODATE |GFS2_RDF_CHECK ); + rgd->rd_flags |= (rl_flags |GFS2_RDF_CHECK );if (rgd->rd_rgl->rl_unlinked ==0 ) rgd->rd_flags &= ~GFS2_RDF_CHECK ; rgd->rd_free =be32_to_cpu (rgd->rd_rgl->rl_free);
Signature · 1 line
2.17.2
PATCH 3/18 gfs2: slow the deluge of io error messages
In reply to Bob PetersonWhen an io error is hit, it calls gfs2_io_error_bh_i for every journal buffer it can't write. Since we changed gfs2_io_error_bh_i recently to withdraw later in the cycle, it sends a flood of errors to the console. This patch checks for the file system already being withdrawn, and if so, doesn't send more messages. It doesn't stop the flood of messages, but it slows it down and keeps it more reasonable.
--- fs/gfs2/incore.h | 1 + fs/gfs2/log.c | 7 +++++-- fs/gfs2/util.c | 13 +++++++------ 3 files changed, 13 insertions(+), 8 deletions(-)
fs/gfs2/incore.h +1 -0
@@ -623,6 +623,7 @@ enum {SDF_RORECOVERY =7 ,/* read only recovery */ SDF_SKIP_DLM_UNLOCK =8 ,SDF_FORCE_AIL_FLUSH =9 , + SDF_AIL1_IO_ERROR = 10, }; enum gfs2_freeze_state {
fs/gfs2/log.c +5 -2
@@ -108,7 +108,9 @@ __acquires(&sdp->sd_ail_lock)gfs2_assert (sdp, bd->bd_tr == tr);if (!buffer_busy (bh)) { -if (!buffer_uptodate (bh)) { +if (!buffer_uptodate (bh) && + !test_and_set_bit (SDF_AIL1_IO_ERROR , + &sdp->sd_flags)) {gfs2_io_error_bh (sdp, bh); *withdraw = true; }
@@ -206,7 +208,8 @@ static void gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,gfs2_assert (sdp, bd->bd_tr == tr);if (buffer_busy (bh))continue ; -if (!buffer_uptodate (bh)) { +if (!buffer_uptodate (bh) && + !test_and_set_bit (SDF_AIL1_IO_ERROR , &sdp->sd_flags)) {gfs2_io_error_bh (sdp, bh); *withdraw = true; }
fs/gfs2/util.c +7 -6
@@ -259,12 +259,13 @@ void gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh, const char *function, char *file, unsigned int line, bool withdraw) { - fs_err(sdp, - "fatal: I/O error\n" - " block = %llu\n" -" function = %s, file = %s, line = %u\n" , - (unsigned long long )bh->b_blocknr, - function, file, line); + if (!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) + fs_err(sdp, + "fatal: I/O error\n" + " block = %llu\n" +" function = %s, file = %s, line = %u\n" , + (unsigned long long )bh->b_blocknr, + function, file, line);if (withdraw)gfs2_lm_withdraw (sdp,NULL ); }
Signature · 1 line
2.17.2
PATCH 4/18 gfs2: Use fs_* functions instead of pr_* function where we can
In reply to Bob PetersonBefore this patch, various errors and messages were reported using the pr_* functions: pr_err, pr_warn, pr_info, etc., but that does not tell you which gfs2 mount had the problem, which is often vital to debugging. This patch changes the calls from pr_* to fs_* in most of the messages so that the file system id is printed along with the message.
--- fs/gfs2/dir.c | 21 ++++++++++++--------- fs/gfs2/glock.c | 17 +++++++++-------- fs/gfs2/lock_dlm.c | 10 +++++----- fs/gfs2/rgrp.c | 28 +++++++++++++++++----------- fs/gfs2/trans.c | 15 ++++++++------- fs/gfs2/util.h | 2 +- 6 files changed, 52 insertions(+), 41 deletions(-)
fs/gfs2/dir.c +12 -9
@@ -506,7 +506,8 @@ static int gfs2_dirent_gather(const struct gfs2_dirent *dent,* For now the most important thing is to check that the various sizes * are correct. */ -static int gfs2_check_dirent (struct gfs2_dirent *dent,unsigned int offset, +static int gfs2_check_dirent (struct gfs2_sbd *sdp, +struct gfs2_dirent *dent,unsigned int offset,unsigned int size,unsigned int len,int first) {const char *msg ="gfs2_dirent too small" ;
@@ -528,12 +529,12 @@ static int gfs2_check_dirent(struct gfs2_dirent *dent, unsigned int offset, goto error;return 0 ; error: -pr_warn ("%s: %s (%s)\n" , +fs_warn (sdp,"%s: %s (%s)\n" , __func__, msg, first ?"first in block" :"not first in block" );return -EIO ; } -static int gfs2_dirent_offset (const void *buf) +static int gfs2_dirent_offset (struct gfs2_sbd *sdp,const void *buf) {const struct gfs2_meta_header *h = buf;int offset;
@@ -552,7 +553,8 @@ static int gfs2_dirent_offset(const void *buf) }return offset; wrong_type: -pr_warn ("%s: wrong block type %u\n" , __func__,be32_to_cpu (h->mh_type)); +fs_warn (sdp,"%s: wrong block type %u\n" , __func__, +be32_to_cpu (h->mh_type));return -1 ; }
@@ -566,7 +568,7 @@ static struct gfs2_dirent *gfs2_dirent_scan(struct inode *inode, void *buf,unsigned size;int ret =0 ; - ret =gfs2_dirent_offset (buf); + ret =gfs2_dirent_offset (GFS2_SB (inode), buf);if (ret <0 ) goto consist_inode;
@@ -574,7 +576,7 @@ static struct gfs2_dirent *gfs2_dirent_scan(struct inode *inode, void *buf, prev =NULL ; dent = buf + offset; size =be16_to_cpu (dent->de_rec_len); -if (gfs2_check_dirent (dent, offset, size, len,1 )) +if (gfs2_check_dirent (GFS2_SB (inode), dent, offset, size, len,1 )) goto consist_inode; do { ret = scan(dent, name, opaque);
@@ -586,7 +588,8 @@ static struct gfs2_dirent *gfs2_dirent_scan(struct inode *inode, void *buf, prev = dent; dent = buf + offset; size =be16_to_cpu (dent->de_rec_len); -if (gfs2_check_dirent (dent, offset, size, len,0 )) +if (gfs2_check_dirent (GFS2_SB (inode), dent, offset, size, + len,0 )) goto consist_inode; }while (1 );
@@ -1043,7 +1046,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name) len =BIT (dip->i_depth -be16_to_cpu (oleaf->lf_depth)); half_len = len >>1 ;if (!half_len) { -pr_warn ("i_depth %u lf_depth %u index %u\n" , +fs_warn (GFS2_SB (inode),"i_depth %u lf_depth %u index %u\n" , dip->i_depth,be16_to_cpu (oleaf->lf_depth), index);gfs2_consist_inode (dip); error = -EIO ;
@@ -1351,7 +1354,7 @@ static int gfs2_set_cookies(struct gfs2_sbd *sdp, struct buffer_head *bh,if (!sdp->sd_args.ar_loccookie)continue ; offset = (char *)(darr[i]) - - (bh->b_data +gfs2_dirent_offset (bh->b_data)); + (bh->b_data +gfs2_dirent_offset (sdp, bh->b_data)); offset /=GFS2_MIN_DIRENT_SIZE ; offset += leaf_nr * sdp->sd_max_dents_per_leaf; if (offset >= GFS2_USE_HASH_FLAG ||
fs/gfs2/glock.c +9 -8
@@ -494,7 +494,8 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)do_xmote (gl, gh,LM_ST_UNLOCKED );break ;default :/* Everything else */ -pr_err ("wanted %u got %u\n" , gl->gl_target, state); +fs_err (gl->gl_name.ln_sbd,"wanted %u got %u\n" , + gl->gl_target, state);GLOCK_BUG_ON (gl,1 ); }spin_unlock (&gl->gl_lockref.lock);
@@ -577,7 +578,7 @@ __acquires(&gl->gl_lockref.lock)gfs2_glock_queue_work (gl,0 ); }else if (ret) { -pr_err ("lm_lock ret %d\n" , ret); +fs_err (sdp,"lm_lock ret %d\n" , ret);GLOCK_BUG_ON (gl, !test_bit (SDF_SHUTDOWN , &sdp->sd_flags)); }
@@ -1064,13 +1065,13 @@ __acquires(&gl->gl_lockref.lock)return ; trap_recursive: -pr_err ("original: %pSR\n" , (void *)gh2->gh_ip); -pr_err ("pid: %d\n" ,pid_nr (gh2->gh_owner_pid)); -pr_err ("lock type: %d req lock state : %d\n" , +fs_err (sdp,"original: %pSR\n" , (void *)gh2->gh_ip); +fs_err (sdp,"pid: %d\n" ,pid_nr (gh2->gh_owner_pid)); +fs_err (sdp,"lock type: %d req lock state : %d\n" , gh2->gh_gl->gl_name.ln_type, gh2->gh_state); -pr_err ("new: %pSR\n" , (void *)gh->gh_ip); -pr_err ("pid: %d\n" ,pid_nr (gh->gh_owner_pid)); -pr_err ("lock type: %d req lock state : %d\n" , +fs_err (sdp,"new: %pSR\n" , (void *)gh->gh_ip); +fs_err (sdp,"pid: %d\n" ,pid_nr (gh->gh_owner_pid)); +fs_err (sdp,"lock type: %d req lock state : %d\n" , gh->gh_gl->gl_name.ln_type, gh->gh_state);gfs2_dump_glock (NULL , gl);BUG ();
fs/gfs2/lock_dlm.c +5 -5
@@ -177,14 +177,14 @@ static void gdlm_bast(void *arg, int mode)gfs2_glock_cb (gl,LM_ST_SHARED );break ;default : -pr_err ("unknown bast mode %d\n" , mode); +fs_err (gl->gl_name.ln_sbd,"unknown bast mode %d\n" , mode);BUG (); } }/* convert gfs lock-state to dlm lock-mode */ -static int make_mode (const unsigned int lmstate) +static int make_mode (struct gfs2_sbd *sdp,const unsigned int lmstate) {switch (lmstate) {case LM_ST_UNLOCKED :
@@ -196,7 +196,7 @@ static int make_mode(const unsigned int lmstate)case LM_ST_SHARED :return DLM_LOCK_PR ; } -pr_err ("unknown LM state %d\n" , lmstate); +fs_err (sdp,"unknown LM state %d\n" , lmstate);BUG ();return -1 ; }
@@ -257,7 +257,7 @@ static int gdlm_lock(struct gfs2_glock *gl, unsigned int req_state,u32 lkf;char strname[GDLM_STRNAME_BYTES ] ="" ; - req =make_mode (req_state); + req =make_mode (gl->gl_name.ln_sbd, req_state); lkf =make_flags (gl, flags, req);gfs2_glstats_inc (gl,GFS2_LKS_DCOUNT );gfs2_sbstats_inc (gl,GFS2_LKS_DCOUNT );
@@ -309,7 +309,7 @@ static void gdlm_put_lock(struct gfs2_glock *gl) error =dlm_unlock (ls->ls_dlm, gl->gl_lksb.sb_lkid,DLM_LKF_VALBLK ,NULL , gl);if (error) { -pr_err ("gdlm_unlock %x,%llx err=%d\n" , +fs_err (sdp,"gdlm_unlock %x,%llx err=%d\n" , gl->gl_name.ln_type, (unsigned long long )gl->gl_name.ln_number, error);return ;
fs/gfs2/rgrp.c +17 -11
@@ -101,12 +101,16 @@ static inline void gfs2_setbit(const struct gfs2_rbm *rbm, bool do_clone, cur_state = (*byte1 >> bit) &GFS2_BIT_MASK ;if (unlikely (!valid_change[new_state *4 + cur_state])) { -pr_warn ("buf_blk = 0x%x old_state=%d, new_state=%d\n" , +struct gfs2_sbd *sdp = rbm->rgd->rd_sbd; + +fs_warn (sdp,"buf_blk = 0x%x old_state=%d, new_state=%d\n" , rbm->offset, cur_state, new_state); -pr_warn ("rgrp=0x%llx bi_start=0x%x\n" , - (unsigned long long )rbm->rgd->rd_addr, bi->bi_start); -pr_warn ("bi_offset=0x%x bi_len=0x%x\n" , - bi->bi_offset, bi->bi_len); +fs_warn (sdp,"rgrp=0x%llx bi_start=0x%x biblk: 0x%llx\n" , + (unsigned long long )rbm->rgd->rd_addr, bi->bi_start, + (unsigned long long )bi->bi_bh->b_blocknr); +fs_warn (sdp,"bi_offset=0x%x bi_len=0x%x block=0x%llx\n" , + bi->bi_offset, bi->bi_len, + (unsigned long long )gfs2_rbm_to_block (rbm));dump_stack ();gfs2_consist_rgrpd (rbm->rgd);return ;
@@ -738,11 +742,13 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp)static void gfs2_rindex_print (const struct gfs2_rgrpd *rgd) { -pr_info ("ri_addr = %llu\n" , (unsigned long long )rgd->rd_addr); -pr_info ("ri_length = %u\n" , rgd->rd_length); -pr_info ("ri_data0 = %llu\n" , (unsigned long long )rgd->rd_data0); -pr_info ("ri_data = %u\n" , rgd->rd_data); -pr_info ("ri_bitbytes = %u\n" , rgd->rd_bitbytes); +struct gfs2_sbd *sdp = rgd->rd_sbd; + +fs_info (sdp,"ri_addr = %llu\n" , (unsigned long long )rgd->rd_addr); +fs_info (sdp,"ri_length = %u\n" , rgd->rd_length); +fs_info (sdp,"ri_data0 = %llu\n" , (unsigned long long )rgd->rd_data0); +fs_info (sdp,"ri_data = %u\n" , rgd->rd_data); +fs_info (sdp,"ri_bitbytes = %u\n" , rgd->rd_bitbytes); }/**
@@ -2423,7 +2429,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks, } }if (rbm.rgd->rd_free < *nblocks) { -pr_warn ("nblocks=%u\n" , *nblocks); +fs_warn (sdp,"nblocks=%u\n" , *nblocks); goto rgrp_error; }
fs/gfs2/trans.c +8 -7
@@ -74,13 +74,13 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,return error; } -static void gfs2_print_trans (const struct gfs2_trans *tr) +static void gfs2_print_trans (struct gfs2_sbd *sdp,const struct gfs2_trans *tr) { -pr_warn ("Transaction created at: %pSR\n" , (void *)tr->tr_ip); -pr_warn ("blocks=%u revokes=%u reserved=%u touched=%u\n" , +fs_warn (sdp,"Transaction created at: %pSR\n" , (void *)tr->tr_ip); +fs_warn (sdp,"blocks=%u revokes=%u reserved=%u touched=%u\n" , tr->tr_blocks, tr->tr_revokes, tr->tr_reserved,test_bit (TR_TOUCHED , &tr->tr_flags)); -pr_warn ("Buf %u/%u Databuf %u/%u Revoke %u/%u\n" , +fs_warn (sdp,"Buf %u/%u Databuf %u/%u Revoke %u/%u\n" , tr->tr_num_buf_new, tr->tr_num_buf_rm, tr->tr_num_databuf_new, tr->tr_num_databuf_rm, tr->tr_num_revoke, tr->tr_num_revoke_rm);
@@ -109,7 +109,7 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)if (gfs2_assert_withdraw (sdp, (nbuf <= tr->tr_blocks) && (tr->tr_num_revoke <= tr->tr_revokes))) -gfs2_print_trans (tr); +gfs2_print_trans (sdp, tr);gfs2_log_commit (sdp, tr);if (alloced && !test_bit (TR_ATTACHED , &tr->tr_flags))
@@ -225,12 +225,13 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)set_bit (GLF_DIRTY , &bd->bd_gl->gl_flags); mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;if (unlikely (mh->mh_magic !=cpu_to_be32 (GFS2_MAGIC ))) { -pr_err ("Attempting to add uninitialised block to journal (inplace block=%lld)\n" , +fs_err (sdp,"Attempting to add uninitialised block to " +"journal (inplace block=%lld)\n" , (unsigned long long )bd->bd_bh->b_blocknr);BUG (); }if (unlikely (state ==SFS_FROZEN )) { -printk (KERN_INFO "GFS2:adding buf while frozen\n" ); +fs_info (sdp,"GFS2:adding buf while frozen\n" );gfs2_assert_withdraw (sdp,0 ); }gfs2_pin (sdp, bd->bd_bh);
fs/gfs2/util.h +1 -1
@@ -86,7 +86,7 @@ static inline int gfs2_meta_check(struct gfs2_sbd *sdp,struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;u32 magic =be32_to_cpu (mh->mh_magic);if (unlikely (magic !=GFS2_MAGIC )) { -pr_err ("Magic number missing at %llu\n" , +fs_err (sdp,"Magic number missing at %llu\n" , (unsigned long long )bh->b_blocknr);return -EIO ; }
Signature · 1 line
2.17.2
PATCH 5/18 gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd
In reply to Bob PetersonFrom: Andrew Price <[email protected]>
When alloc_percpu() fails, sdp gets freed but sb->s_fs_info still points to the same address. Move the assignment after that error check so that s_fs_info can only point to a valid sdp or NULL, which is checked for later in the error path, in gfs2_kill_super().
--- fs/gfs2/ops_fstype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/ops_fstype.c +1 -1
@@ -72,13 +72,13 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)if (!sdp)return NULL ; - sb->s_fs_info = sdp; sdp->sd_vfs = sb; sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats);if (!sdp->sd_lkstats) {kfree (sdp);return NULL ; } + sb->s_fs_info = sdp;set_bit (SDF_NOJOURNALID , &sdp->sd_flags);gfs2_tune_init (&sdp->sd_tune);
Signature · 1 line
2.17.2
PATCH 6/18 GFS2: Flush the GFS2 delete workqueue before stopping the kernel threads
In reply to Bob PetersonFrom: Tim Smith <[email protected]>
Flushing the workqueue can cause operations to happen which might call gfs2_log_reserve(), or get stuck waiting for locks taken by such operations. gfs2_log_reserve() can io_schedule(). If this happens, it will never wake because the only thing which can wake it is gfs2_logd() which was already stopped.
This causes umount of a gfs2 filesystem to wedge permanently if, for example, the umount immediately follows a large delete operation.
When this occured, the following stack trace was obtained from the umount command
[<ffffffff81087968>] flush_workqueue+0x1c8/0x520 [<ffffffffa0666e29>] gfs2_make_fs_ro+0x69/0x160 [gfs2] [<ffffffffa0667279>] gfs2_put_super+0xa9/0x1c0 [gfs2] [<ffffffff811b7edf>] generic_shutdown_super+0x6f/0x100 [<ffffffff811b7ff7>] kill_block_super+0x27/0x70 [<ffffffffa0656a71>] gfs2_kill_sb+0x71/0x80 [gfs2] [<ffffffff811b792b>] deactivate_locked_super+0x3b/0x70 [<ffffffff811b79b9>] deactivate_super+0x59/0x60 [<ffffffff811d2998>] cleanup_mnt+0x58/0x80 [<ffffffff811d2a12>] __cleanup_mnt+0x12/0x20 [<ffffffff8108c87d>] task_work_run+0x7d/0xa0 [<ffffffff8106d7d9>] exit_to_usermode_loop+0x73/0x98 [<ffffffff81003961>] syscall_return_slowpath+0x41/0x50 [<ffffffff815a594c>] int_ret_from_sys_call+0x25/0x8f
[<ffffffffffffffff>] 0xffffffffffffffff
--- fs/gfs2/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/super.c +1 -1
@@ -854,10 +854,10 @@ static int gfs2_make_fs_ro(struct gfs2_sbd *sdp)if (error && !test_bit (SDF_SHUTDOWN , &sdp->sd_flags))return error; +flush_workqueue (gfs2_delete_workqueue);kthread_stop (sdp->sd_quotad_process);kthread_stop (sdp->sd_logd_process); -flush_workqueue (gfs2_delete_workqueue);gfs2_quota_sync (sdp->sd_vfs,0 );gfs2_statfs_sync (sdp->sd_vfs,0 );
Signature · 1 line
2.17.2
PATCH 7/18 gfs2: getlabel support
In reply to Bob PetersonFrom: Steve Whitehouse <[email protected]>
Add support for the GETFSLABEL ioctl in gfs2. I tested this patch and it works as expected.
--- fs/gfs2/file.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/gfs2/file.c +14 -0
@@ -314,6 +314,17 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr)return do_gfs2_set_flags (filp, gfsflags, mask); } +static int gfs2_getlabel (struct file *filp,char __user *label) +{ +struct inode *inode =file_inode (filp); +struct gfs2_sbd *sdp =GFS2_SB (inode); + +if (copy_to_user (label, sdp->sd_sb.sb_locktable,GFS2_LOCKNAME_LEN )) +return -EFAULT ; + +return 0 ; +} +static long gfs2_ioctl (struct file *filp,unsigned int cmd,unsigned long arg) {switch (cmd) {
@@ -323,7 +334,10 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)return gfs2_set_flags (filp, (u32 __user *)arg);case FITRIM :return gfs2_fitrim (filp, (void __user *)arg); +case FS_IOC_GETFSLABEL : +return gfs2_getlabel (filp, (char __user *)arg); } +return -ENOTTY ; }
Signature · 1 line
2.17.2
PATCH 8/18 gfs2: Always check the result of gfs2_rbm_from_block
In reply to Bob PetersonFrom: Andreas Gruenbacher <[email protected]>
When gfs2_rbm_from_block fails, the rbm it returns is undefined, so we always want to make sure gfs2_rbm_from_block has succeeded before looking at the rbm.
--- fs/gfs2/rgrp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/gfs2/rgrp.c +8 -3
@@ -2233,7 +2233,8 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart,return NULL ; } -gfs2_rbm_from_block (&rbm, bstart); +if (WARN_ON_ONCE (gfs2_rbm_from_block (&rbm, bstart))) +return NULL ;while (blen--) { bi =rbm_bi (&rbm);if (bi != bi_prev) {
@@ -2366,7 +2367,10 @@ static void gfs2_set_alloc_start(struct gfs2_rbm *rbm,else goal = rbm->rgd->rd_last_alloc + rbm->rgd->rd_data0; -gfs2_rbm_from_block (rbm, goal); +if (WARN_ON_ONCE (gfs2_rbm_from_block (rbm, goal))) { + rbm->bii =0 ; + rbm->offset =0 ; + } }/**
@@ -2575,7 +2579,8 @@ int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr, unsigned int type) rbm.rgd = rgd; error =gfs2_rbm_from_block (&rbm, no_addr); -WARN_ON_ONCE (error !=0 ); +if (WARN_ON_ONCE (error)) + goto fail;if (gfs2_testbit (&rbm, false) != type) error = -ESTALE ;
Signature · 1 line
2.17.2
PATCH 9/18 gfs2: Clean up out-of-bounds check in gfs2_rbm_from_block
In reply to Bob PetersonFrom: Andreas Gruenbacher <[email protected]>
We already have a function that checks if a block is within a resource group, so use that in gfs2_rbm_from_block as well.
--- fs/gfs2/rgrp.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/gfs2/rgrp.c +2 -7
@@ -273,15 +273,10 @@ static u32 gfs2_bitfit(const u8 *buf, const unsigned int len,static int gfs2_rbm_from_block (struct gfs2_rbm *rbm,u64 block) { -u64 rblock = block - rbm->rgd->rd_data0; - -if (WARN_ON_ONCE (rblock >UINT_MAX )) -return -EINVAL ; -if (block >= rbm->rgd->rd_data0 + rbm->rgd->rd_data) +if (!rgrp_contains_block (rbm->rgd, block))return -E2BIG ; - rbm->bii =0 ; - rbm->offset = (u32)(rblock); + rbm->offset = block - rbm->rgd->rd_data0;/* Check if the block is within the first block */ if (rbm->offset <rbm_bi (rbm)->bi_blocks)return 0 ;
Signature · 1 line
2.17.2
PATCH 10/18 gfs2: Move rs_{sizehint, rgd_gh} fields into the inode
In reply to Bob PetersonFrom: Andreas Gruenbacher <[email protected]>
Move the rs_sizehint and rs_rgd_gh fields from struct gfs2_blkreserv into the inode: they are more closely related to the inode than to a particular reservation.
--- fs/gfs2/file.c | 4 ++-- fs/gfs2/incore.h | 6 ++---- fs/gfs2/main.c | 2 ++ fs/gfs2/rgrp.c | 16 +++++++--------- 4 files changed, 13 insertions(+), 15 deletions(-)
fs/gfs2/file.c +2 -2
@@ -361,8 +361,8 @@ static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size)size_t blks = (size + sdp->sd_sb.sb_bsize -1 ) >> sdp->sd_sb.sb_bsize_shift;int hint =min_t (size_t,INT_MAX , blks); -if (hint >atomic_read (&ip->i_res.rs_sizehint)) -atomic_set (&ip->i_res.rs_sizehint, hint); +if (hint >atomic_read (&ip->i_sizehint)) +atomic_set (&ip->i_sizehint, hint); }/**
fs/gfs2/incore.h +2 -4
@@ -309,10 +309,6 @@ struct gfs2_qadata { /* quota allocation data */*/ struct gfs2_blkreserv { -/* components used during write (step 1): */ -atomic_t rs_sizehint;/* hint of the write size */ - -struct gfs2_holder rs_rgd_gh;/* Filled in by get_local_rgrp */ struct rb_node rs_node;/* link to other block reservations */ struct gfs2_rbm rs_rbm;/* Start of reservation */ u32 rs_free;/* how many blocks are still free */
@@ -417,8 +413,10 @@ struct gfs2_inode {struct gfs2_holder i_iopen_gh;struct gfs2_holder i_gh;/* for prepare/commit_write only */ struct gfs2_qadata *i_qadata;/* quota allocation data */ +struct gfs2_holder i_rgd_gh;struct gfs2_blkreserv i_res;/* rgrp multi-block reservation */ u64 i_goal;/* goal block for allocations */ +atomic_t i_sizehint;/* hint of the write size */ struct rw_semaphore i_rw_mutex;struct list_head i_ordered;struct list_head i_trunc_list;
fs/gfs2/main.c +2 -0
@@ -39,9 +39,11 @@ static void gfs2_init_inode_once(void *foo)struct gfs2_inode *ip = foo;inode_init_once (&ip->i_inode); +atomic_set (&ip->i_sizehint,0 );init_rwsem (&ip->i_rw_mutex);INIT_LIST_HEAD (&ip->i_trunc_list); ip->i_qadata =NULL ; +gfs2_holder_mark_uninitialized (&ip->i_rgd_gh);memset (&ip->i_res,0 ,sizeof (ip->i_res));RB_CLEAR_NODE (&ip->i_res.rs_node); ip->i_hash_cache =NULL ;
fs/gfs2/rgrp.c +7 -9
@@ -1565,7 +1565,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,if (S_ISDIR (inode->i_mode)) extlen =1 ;else { - extlen =max_t (u32,atomic_read (&rs->rs_sizehint), ap->target); + extlen =max_t (u32,atomic_read (&ip->i_sizehint), ap->target); extlen =clamp (extlen,RGRP_RSRV_MINBLKS , free_blocks); }if ((rgd->rd_free_clone < rgd->rd_reserved) || (free_blocks < extlen))
@@ -2077,7 +2077,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap) } error =gfs2_glock_nq_init (rs->rs_rbm.rgd->rd_gl,LM_ST_EXCLUSIVE , flags, - &rs->rs_rgd_gh); + &ip->i_rgd_gh);if (unlikely (error))return error; if (!gfs2_rs_active(rs) && (loops < 2) &&
@@ -2086,7 +2086,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap)if (sdp->sd_args.ar_rgrplvb) { error =update_rgrp_lvb (rs->rs_rbm.rgd);if (unlikely (error)) { -gfs2_glock_dq_uninit (&rs->rs_rgd_gh); +gfs2_glock_dq_uninit (&ip->i_rgd_gh);return error; } }
@@ -2129,7 +2129,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap)/* Unlock rgrp if required */ if (!rg_locked) -gfs2_glock_dq_uninit (&rs->rs_rgd_gh); +gfs2_glock_dq_uninit (&ip->i_rgd_gh); next_rgrp:/* Find the next rgrp, and continue looking */ if (gfs2_select_rgrp (&rs->rs_rbm.rgd, begin))
@@ -2166,10 +2166,8 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap)void gfs2_inplace_release (struct gfs2_inode *ip) { -struct gfs2_blkreserv *rs = &ip->i_res; - -if (gfs2_holder_initialized (&rs->rs_rgd_gh)) -gfs2_glock_dq_uninit (&rs->rs_rgd_gh); +if (gfs2_holder_initialized (&ip->i_rgd_gh)) +gfs2_glock_dq_uninit (&ip->i_rgd_gh); }/**
@@ -2328,7 +2326,7 @@ static void gfs2_adjust_reservation(struct gfs2_inode *ip, goto out;/* We used up our block reservation, so we should reserve more blocks next time. */ -atomic_add (RGRP_RSRV_ADDBLKS , &rs->rs_sizehint); +atomic_add (RGRP_RSRV_ADDBLKS , &ip->i_sizehint); }__rs_deltree (rs); }
Signature · 1 line
2.17.2
PATCH 11/18 gfs2: Remove unused RGRP_RSRV_MINBYTES definition
In reply to Bob PetersonFrom: Andreas Gruenbacher <[email protected]>
This definition is only used to define RGRP_RSRV_MINBLKS, with no benefit over defining RGRP_RSRV_MINBLKS directly.
In addition, instead of forcing RGRP_RSRV_MINBLKS to be of type u32, cast it to that type where that type is required.
--- fs/gfs2/rgrp.c | 2 +- fs/gfs2/rgrp.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
fs/gfs2/rgrp.c +1 -1
@@ -1566,7 +1566,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip, extlen =1 ; else { extlen =max_t (u32,atomic_read (&ip->i_sizehint), ap->target); - extlen =clamp (extlen,RGRP_RSRV_MINBLKS , free_blocks); + extlen =clamp (extlen, (u32 )RGRP_RSRV_MINBLKS , free_blocks); }if ((rgd->rd_free_clone < rgd->rd_reserved) || (free_blocks < extlen))return ;
fs/gfs2/rgrp.h +1 -2
@@ -18,8 +18,7 @@* By reserving 32 blocks at a time, we can optimize / shortcut how we search * through the bitmaps by looking a word@a time. */ -#define RGRP_RSRV_MINBYTES 8 -#define RGRP_RSRV_MINBLKS ((u32)(RGRP_RSRV_MINBYTES * GFS2_NBBY)) +#define RGRP_RSRV_MINBLKS 32#define RGRP_RSRV_ADDBLKS 64struct gfs2_rgrpd ;
Signature · 1 line
2.17.2
PATCH 12/18 gfs2: Rename bitmap.bi_{len => bytes}
In reply to Bob PetersonFrom: Andreas Gruenbacher <[email protected]>
This field indicates the size of the bitmap in bytes, similar to how the bi_blocks field indicates the size of the bitmap in blocks.
In count_unlinked, replace an instance of bi_bytes * GFS2_NBBY by bi_blocks.
--- fs/gfs2/incore.h | 2 +- fs/gfs2/lops.c | 2 +- fs/gfs2/rgrp.c | 32 ++++++++++++++++---------------- 3 files changed, 18 insertions(+), 18 deletions(-)
fs/gfs2/incore.h +1 -1
@@ -92,7 +92,7 @@ struct gfs2_bitmap {unsigned long bi_flags;u32 bi_offset;u32 bi_start; -u32 bi_len; +u32 bi_bytes;u32 bi_blocks; };
fs/gfs2/lops.c +1 -1
@@ -81,7 +81,7 @@ static void maybe_release_space(struct gfs2_bufdata *bd)if (sdp->sd_args.ar_discard)gfs2_rgrp_send_discards (sdp, rgd->rd_data0, bd->bd_bh, bi,1 ,NULL );memcpy (bi->bi_clone + bi->bi_offset, - bd->bd_bh->b_data + bi->bi_offset, bi->bi_len); + bd->bd_bh->b_data + bi->bi_offset, bi->bi_bytes);clear_bit (GBF_FULL , &bi->bi_flags); rgd->rd_free_clone = rgd->rd_free; rgd->rd_extfail_pt = rgd->rd_free;
fs/gfs2/rgrp.c +16 -16
@@ -90,7 +90,7 @@ static inline void gfs2_setbit(const struct gfs2_rbm *rbm, bool do_clone, {unsigned char *byte1, *byte2, *end, cur_state;struct gfs2_bitmap *bi =rbm_bi (rbm); -unsigned int buflen = bi->bi_len; +unsigned int buflen = bi->bi_bytes;const unsigned int bit = (rbm->offset %GFS2_NBBY ) *GFS2_BIT_SIZE ; byte1 = bi->bi_bh->b_data + bi->bi_offset + (rbm->offset /GFS2_NBBY );
@@ -108,8 +108,8 @@ static inline void gfs2_setbit(const struct gfs2_rbm *rbm, bool do_clone,fs_warn (sdp,"rgrp=0x%llx bi_start=0x%x biblk: 0x%llx\n" , (unsigned long long )rbm->rgd->rd_addr, bi->bi_start, (unsigned long long )bi->bi_bh->b_blocknr); -fs_warn (sdp,"bi_offset=0x%x bi_len=0x%x block=0x%llx\n" , - bi->bi_offset, bi->bi_len, +fs_warn (sdp,"bi_offset=0x%x bi_bytes=0x%x block=0x%llx\n" , + bi->bi_offset, bi->bi_bytes, (unsigned long long )gfs2_rbm_to_block (rbm));dump_stack ();gfs2_consist_rgrpd (rbm->rgd);
@@ -381,7 +381,7 @@ static u32 gfs2_free_extlen(const struct gfs2_rbm *rrbm, u32 len)if (bi->bi_clone) start = bi->bi_clone; start += bi->bi_offset; - end = start + bi->bi_len; + end = start + bi->bi_bytes;BUG_ON (rbm.offset &3 ); start += (rbm.offset /GFS2_NBBY ); bytes =min_t (u32, len /GFS2_NBBY , (end - start));
@@ -466,7 +466,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd) count[x] +=gfs2_bitcount (rgd, bi->bi_bh->b_data + bi->bi_offset, - bi->bi_len, x); + bi->bi_bytes, x); }if (count[0 ] != rgd->rd_free) {
@@ -781,21 +781,21 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd) bytes = bytes_left; bi->bi_offset =sizeof (struct gfs2_rgrp ); bi->bi_start =0 ; - bi->bi_len = bytes; + bi->bi_bytes = bytes; bi->bi_blocks = bytes *GFS2_NBBY ;/* header block */ }else if (x ==0 ) { bytes = sdp->sd_sb.sb_bsize -sizeof (struct gfs2_rgrp ); bi->bi_offset =sizeof (struct gfs2_rgrp ); bi->bi_start =0 ; - bi->bi_len = bytes; + bi->bi_bytes = bytes; bi->bi_blocks = bytes *GFS2_NBBY ;/* last block */ }else if (x +1 == length) { bytes = bytes_left; bi->bi_offset =sizeof (struct gfs2_meta_header ); bi->bi_start = rgd->rd_bitbytes - bytes_left; - bi->bi_len = bytes; + bi->bi_bytes = bytes; bi->bi_blocks = bytes *GFS2_NBBY ;/* other blocks */ }else {
@@ -803,7 +803,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)sizeof (struct gfs2_meta_header ); bi->bi_offset =sizeof (struct gfs2_meta_header ); bi->bi_start = rgd->rd_bitbytes - bytes_left; - bi->bi_len = bytes; + bi->bi_bytes = bytes; bi->bi_blocks = bytes *GFS2_NBBY ; }
@@ -815,11 +815,11 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)return -EIO ; } bi = rgd->rd_bits + (length -1 ); -if ((bi->bi_start + bi->bi_len) *GFS2_NBBY != rgd->rd_data) { +if ((bi->bi_start + bi->bi_bytes) *GFS2_NBBY != rgd->rd_data) {if (gfs2_consist_rgrpd (rgd)) {gfs2_rindex_print (rgd);fs_err (sdp,"start=%u len=%u offset=%u\n" , - bi->bi_start, bi->bi_len, bi->bi_offset); + bi->bi_start, bi->bi_bytes, bi->bi_offset); }return -EIO ; }
@@ -1146,8 +1146,8 @@ static u32 count_unlinked(struct gfs2_rgrpd *rgd) goal =0 ; buffer = bi->bi_bh->b_data + bi->bi_offset;WARN_ON (!buffer_uptodate (bi->bi_bh)); -while (goal < bi->bi_len *GFS2_NBBY ) { - goal =gfs2_bitfit (buffer, bi->bi_len, goal, +while (goal < bi->bi_blocks) { + goal =gfs2_bitfit (buffer, bi->bi_bytes, goal,GFS2_BLKST_UNLINKED );if (goal ==BFITNOENT )break ;
@@ -1319,7 +1319,7 @@ int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,u32 trimmed =0 ;u8 diff; -for (x =0 ; x < bi->bi_len; x++) { +for (x =0 ; x < bi->bi_bytes; x++) {const u8 *clone = bi->bi_clone ? bi->bi_clone : bi->bi_bh->b_data; clone += bi->bi_offset; clone += x;
@@ -1752,7 +1752,7 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext,if (state !=GFS2_BLKST_UNLINKED && bi->bi_clone) buffer = bi->bi_clone + bi->bi_offset; initial_offset = rbm->offset; - offset =gfs2_bitfit (buffer, bi->bi_len, rbm->offset, state); + offset =gfs2_bitfit (buffer, bi->bi_bytes, rbm->offset, state);if (offset ==BFITNOENT ) goto bitmap_full; rbm->offset = offset;
@@ -2236,7 +2236,7 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart, GFP_NOFS | __GFP_NOFAIL);memcpy (bi->bi_clone + bi->bi_offset, bi->bi_bh->b_data + bi->bi_offset, - bi->bi_len); + bi->bi_bytes); }gfs2_trans_add_meta (rbm.rgd->rd_gl, bi->bi_bh); bi_prev = bi;
Signature · 1 line
2.17.2
PATCH 13/18 gfs2: Fix some minor typos
In reply to Bob PetersonFrom: Andreas Gruenbacher <[email protected]>
--- fs/gfs2/quota.c | 2 +- fs/gfs2/rgrp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/gfs2/quota.c +1 -1
@@ -1183,7 +1183,7 @@ static int print_message(struct gfs2_quota_data *qd, char *type)* * Returns: 0 on success. * min_req = ap->min_target ? ap->min_target : ap->target; -* quota must allow atleast min_req blks for success and +* quota must allow at least min_req blks for success and * ap->allowed is set to the number of blocks allowed * * -EDQUOT otherwise, quota violation. ap->allowed is set to number
fs/gfs2/rgrp.c +2 -2
@@ -2023,7 +2023,7 @@ static inline int fast_to_acquire(struct gfs2_rgrpd *rgd)* We try our best to find an rgrp that has at least ap->target blocks * available. After a couple of passes (loops == 2), the prospects of finding * such an rgrp diminish. At this stage, we return the first rgrp that has -* atleast ap->min_target blocks available. Either way, we set ap->allowed to +* at least ap->min_target blocks available. Either way, we set ap->allowed to * the number of blocks available in the chosen rgrp. * * Returns: 0 on success,
@@ -2092,7 +2092,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap) } } -/* Skip unuseable resource groups */ +/* Skip unusable resource groups */ if ((rs->rs_rbm.rgd->rd_flags & (GFS2_RGF_NOALLOC |GFS2_RDF_ERROR )) || (loops ==0 && ap->target > rs->rs_rbm.rgd->rd_extfail_pt))
Signature · 1 line
2.17.2
PATCH 14/18 gfs2: Fix marking bitmaps non-full
In reply to Bob PetersonFrom: Andreas Gruenbacher <[email protected]>
Reservations in gfs can span multiple gfs2_bitmaps (but they won't span multiple resource groups). When removing a reservation, we want to clear the GBF_FULL flags of all involved gfs2_bitmaps, not just that of the first bitmap.
--- fs/gfs2/rgrp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/gfs2/rgrp.c +11 -2
@@ -641,7 +641,10 @@ static void __rs_deltree(struct gfs2_blkreserv *rs)RB_CLEAR_NODE (&rs->rs_node);if (rs->rs_free) { -struct gfs2_bitmap *bi =rbm_bi (&rs->rs_rbm); +u64 last_block =gfs2_rbm_to_block (&rs->rs_rbm) + + rs->rs_free -1 ; +struct gfs2_rbm last_rbm = { .rgd = rs->rs_rbm.rgd, }; +struct gfs2_bitmap *start, *last;/* return reserved blocks to the rgrp */ BUG_ON (rs->rs_rbm.rgd->rd_reserved < rs->rs_free);
@@ -652,7 +655,13 @@ static void __rs_deltree(struct gfs2_blkreserv *rs)it will force the number to be recalculated later. */ rgd->rd_extfail_pt += rs->rs_free; rs->rs_free =0 ; -clear_bit (GBF_FULL , &bi->bi_flags); +if (gfs2_rbm_from_block (&last_rbm, last_block)) +return ; + start =rbm_bi (&rs->rs_rbm); + last =rbm_bi (&last_rbm); +do +clear_bit (GBF_FULL , &start->bi_flags); +while (start++ != last); } }
Signature · 1 line
2.17.2
PATCH 15/18 gfs2: Remove unnecessary gfs2_rlist_alloc parameter
In reply to Bob PetersonThe state parameter of gfs2_rlist_alloc is set to LM_ST_EXCLUSIVE in all calls, so remove it and hardcode that state in gfs2_rlist_alloc instead.
--- fs/gfs2/dir.c | 2 +- fs/gfs2/rgrp.c | 5 ++--- fs/gfs2/rgrp.h | 2 +- fs/gfs2/xattr.c | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-)
fs/gfs2/dir.c +1 -1
@@ -2021,7 +2021,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, l_blocks++; } -gfs2_rlist_alloc (&rlist,LM_ST_EXCLUSIVE ); +gfs2_rlist_alloc (&rlist);for (x =0 ; x < rlist.rl_rgrps; x++) {struct gfs2_rgrpd *rgd =gfs2_glock2rgrp (rlist.rl_ghs[x].gh_gl);
fs/gfs2/rgrp.c +2 -3
@@ -2668,13 +2668,12 @@ void gfs2_rlist_add(struct gfs2_inode *ip, struct gfs2_rgrp_list *rlist,* gfs2_rlist_alloc - all RGs have been added to the rlist, now allocate * and initialize an array of glock holders for them * @rlist: the list of resource groups -* @state: the lock state to acquire the RG lock in * * FIXME: Don't use NOFAIL * */ -void gfs2_rlist_alloc (struct gfs2_rgrp_list *rlist,unsigned int state) +void gfs2_rlist_alloc (struct gfs2_rgrp_list *rlist) {unsigned int x;
@@ -2683,7 +2682,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 , +LM_ST_EXCLUSIVE ,0 , &rlist->rl_ghs[x]); }
fs/gfs2/rgrp.h +1 -1
@@ -67,7 +67,7 @@ struct gfs2_rgrp_list {extern void gfs2_rlist_add (struct gfs2_inode *ip,struct gfs2_rgrp_list *rlist,u64 block); -extern void gfs2_rlist_alloc (struct gfs2_rgrp_list *rlist,unsigned int state); +extern void gfs2_rlist_alloc (struct gfs2_rgrp_list *rlist);extern void gfs2_rlist_free (struct gfs2_rgrp_list *rlist);extern u64 gfs2_ri_total (struct gfs2_sbd *sdp);extern void gfs2_rgrp_dump (struct seq_file *seq,const struct gfs2_glock *gl);
fs/gfs2/xattr.c +1 -1
@@ -1299,7 +1299,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)else goto out; -gfs2_rlist_alloc (&rlist,LM_ST_EXCLUSIVE ); +gfs2_rlist_alloc (&rlist);for (x =0 ; x < rlist.rl_rgrps; x++) {struct gfs2_rgrpd *rgd =gfs2_glock2rgrp (rlist.rl_ghs[x].gh_gl);
Signature · 1 line
2.17.2
PATCH 16/18 gfs2: Pass resource group to rgblk_free
In reply to Bob PetersonFrom: Andreas Gruenbacher <[email protected]>
Function rgblk_free can only deal with one resource group at a time, so pass that resource group is as a parameter. Several of the callers already have the resource group at hand, so we only need additional lookup code in a few places.
--- fs/gfs2/bmap.c | 4 ++-- fs/gfs2/dir.c | 5 ++++- fs/gfs2/rgrp.c | 44 ++++++++++++++++---------------------------- fs/gfs2/rgrp.h | 6 ++++-- fs/gfs2/xattr.c | 16 +++++++++------- 5 files changed, 35 insertions(+), 40 deletions(-)
fs/gfs2/bmap.c +2 -2
@@ -1566,7 +1566,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,continue ; }if (bstart) { -__gfs2_free_blocks (ip, bstart, (u32 )blen, meta); +__gfs2_free_blocks (ip, rgd, bstart, (u32 )blen, meta); (*btotal) += blen;gfs2_add_inode_blocks (&ip->i_inode, -blen); }
@@ -1574,7 +1574,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh, blen =1 ; }if (bstart) { -__gfs2_free_blocks (ip, bstart, (u32 )blen, meta); +__gfs2_free_blocks (ip, rgd, bstart, (u32 )blen, meta); (*btotal) += blen;gfs2_add_inode_blocks (&ip->i_inode, -blen); }
fs/gfs2/dir.c +4 -1
@@ -2042,6 +2042,8 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, bh = leaf_bh;for (blk = leaf_no; blk; blk = nblk) { +struct gfs2_rgrpd *rgd; +if (blk != leaf_no) { error =get_leaf (dip, blk, &bh);if (error)
@@ -2052,7 +2054,8 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,if (blk != leaf_no)brelse (bh); -gfs2_free_meta (dip, blk,1 ); + rgd =gfs2_blk2rgrpd (sdp, blk, true); +gfs2_free_meta (dip, rgd, blk,1 );gfs2_add_inode_blocks (&dip->i_inode,-1 ); }
fs/gfs2/rgrp.c +16 -28
110 lines not on this page · raw message
fs/gfs2/rgrp.h +4 -2
@@ -51,8 +51,10 @@ extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n,extern int gfs2_rsqa_alloc (struct gfs2_inode *ip);extern void gfs2_rs_deltree (struct gfs2_blkreserv *rs);extern void gfs2_rsqa_delete (struct gfs2_inode *ip,atomic_t *wcount); -extern void __gfs2_free_blocks (struct gfs2_inode *ip,u64 bstart,u32 blen,int meta); -extern void gfs2_free_meta (struct gfs2_inode *ip,u64 bstart,u32 blen); +extern void __gfs2_free_blocks (struct gfs2_inode *ip,struct gfs2_rgrpd *rgd, +u64 bstart,u32 blen,int meta); +extern void gfs2_free_meta (struct gfs2_inode *ip,struct gfs2_rgrpd *rgd, +u64 bstart,u32 blen);extern void gfs2_free_di (struct gfs2_rgrpd *rgd,struct gfs2_inode *ip);extern void gfs2_unlink_di (struct inode *inode); extern int gfs2_check_blk_type(struct gfs2_sbd *sdp, u64 no_addr,
fs/gfs2/xattr.c +9 -7
@@ -283,7 +283,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, blen++; else {if (bstart) -gfs2_free_meta (ip, bstart, blen); +gfs2_free_meta (ip, rgd, bstart, blen); bstart = bn; blen =1 ; }
@@ -292,7 +292,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,gfs2_add_inode_blocks (&ip->i_inode,-1 ); }if (bstart) -gfs2_free_meta (ip, bstart, blen); +gfs2_free_meta (ip, rgd, bstart, blen);if (prev && !leave) {u32 len;
@@ -1250,6 +1250,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) {struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode);struct gfs2_rgrp_list rlist; +struct gfs2_rgrpd *rgd;struct buffer_head *indbh, *dibh;__be64 *eablk, *end;unsigned int rg_blocks =0 ;
@@ -1302,8 +1303,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)gfs2_rlist_alloc (&rlist);for (x =0 ; x < rlist.rl_rgrps; x++) { -struct gfs2_rgrpd *rgd =gfs2_glock2rgrp (rlist.rl_ghs[x].gh_gl); - + rgd =gfs2_glock2rgrp (rlist.rl_ghs[x].gh_gl); rg_blocks += rgd->rd_length; }
@@ -1320,6 +1320,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) eablk = (__be64 *)(indbh->b_data +sizeof (struct gfs2_meta_header )); bstart =0 ; + rgd =NULL ; blen =0 ;for (; eablk < end; eablk++) {
@@ -1333,8 +1334,9 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) blen++; else {if (bstart) -gfs2_free_meta (ip, bstart, blen); +gfs2_free_meta (ip, rgd, bstart, blen); bstart = bn; + rgd =gfs2_blk2rgrpd (sdp, bstart, true); blen =1 ; }
@@ -1342,7 +1344,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)gfs2_add_inode_blocks (&ip->i_inode,-1 ); }if (bstart) -gfs2_free_meta (ip, bstart, blen); +gfs2_free_meta (ip, rgd, bstart, blen); ip->i_diskflags &= ~GFS2_DIF_EA_INDIRECT ;
@@ -1391,7 +1393,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip)if (error) goto out_gunlock; -gfs2_free_meta (ip, ip->i_eattr,1 ); +gfs2_free_meta (ip, rgd, ip->i_eattr,1 ); ip->i_eattr =0 ;gfs2_add_inode_blocks (&ip->i_inode,-1 );
Signature · 1 line
2.17.2
PATCH 17/18 gfs2: write revokes should traverse sd_ail1_list in reverse
In reply to Bob PetersonAll the other functions that deal with the sd_ail_list run the list from the tail back to the head, iow, in reverse. We should do the same while writing revokes, otherwise we might miss removing entries properly from the list when we hit the limit of how many revokes we can write at one time (based on block size, which determines how many block pointers will fit in the revoke block).
--- fs/gfs2/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/gfs2/log.c +2 -2
@@ -621,7 +621,7 @@ void gfs2_write_revokes(struct gfs2_sbd *sdp)gfs2_ail1_empty (sdp);spin_lock (&sdp->sd_ail_lock); -list_for_each_entry (tr, &sdp->sd_ail1_list, tr_list) { +list_for_each_entry_reverse (tr, &sdp->sd_ail1_list, tr_list) {list_for_each_entry (bd, &tr->tr_ail2_list, bd_ail_st_list) {if (list_empty (&bd->bd_list)) { have_revokes =1 ;
@@ -645,7 +645,7 @@ void gfs2_write_revokes(struct gfs2_sbd *sdp) }gfs2_log_lock (sdp);spin_lock (&sdp->sd_ail_lock); -list_for_each_entry (tr, &sdp->sd_ail1_list, tr_list) { +list_for_each_entry_reverse (tr, &sdp->sd_ail1_list, tr_list) {list_for_each_entry_safe (bd, tmp, &tr->tr_ail2_list, bd_ail_st_list) {if (max_revokes ==0 ) goto out_of_blocks;
Signature · 1 line
2.17.2
PATCH 18/18 gfs2: Fix minor typo: couln't versus couldn't.
In reply to Bob Peterson--- fs/gfs2/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/super.c +1 -1
@@ -971,7 +971,7 @@ void gfs2_freeze_func(struct work_struct *work) error =gfs2_glock_nq_init (sdp->sd_freeze_gl,LM_ST_SHARED ,0 , &freeze_gh);if (error) { -printk (KERN_INFO "GFS2: couln't get freeze lock : %d\n" , error); +printk (KERN_INFO "GFS2: couldn't get freeze lock : %d\n" , error);gfs2_assert_withdraw (sdp,0 ); }else {
Signature · 1 line
2.17.2