Skip to content

Commit bfd93a8

Browse files
committed
Merge tag 'gfs2-4.20.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2
Pull gfs2 updates from Bob Peterson: "We've got 18 patches for this merge window, none of which are very major: - clean up the gfs2 block allocator to prepare for future performance enhancements (Andreas Gruenbacher) - fix a use-after-free problem (Andy Price) - patches that fix gfs2's broken rgrplvb mount option (me) - cleanup patches and error message improvements (me) - enable getlabel support (Steve Whitehouse and Abhi Das) - flush the glock delete workqueue at exit (Tim Smith)" * tag 'gfs2-4.20.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: gfs2: Fix minor typo: couln't versus couldn't. gfs2: write revokes should traverse sd_ail1_list in reverse gfs2: Pass resource group to rgblk_free gfs2: Remove unnecessary gfs2_rlist_alloc parameter gfs2: Fix marking bitmaps non-full gfs2: Fix some minor typos gfs2: Rename bitmap.bi_{len => bytes} gfs2: Remove unused RGRP_RSRV_MINBYTES definition gfs2: Move rs_{sizehint, rgd_gh} fields into the inode gfs2: Clean up out-of-bounds check in gfs2_rbm_from_block gfs2: Always check the result of gfs2_rbm_from_block gfs2: getlabel support GFS2: Flush the GFS2 delete workqueue before stopping the kernel threads gfs2: Don't leave s_fs_info pointing to freed memory in init_sbd gfs2: Use fs_* functions instead of pr_* function where we can gfs2: slow the deluge of io error messages gfs2: Don't set GFS2_RDF_UPTODATE when the lvb is updated gfs2: improve debug information when lvb mismatches are found
2 parents e1cbbf4 + 8e31582 commit bfd93a8

File tree

18 files changed

+218
-154
lines changed

18 files changed

+218
-154
lines changed

fs/gfs2/bmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,15 +1566,15 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,
15661566
continue;
15671567
}
15681568
if (bstart) {
1569-
__gfs2_free_blocks(ip, bstart, (u32)blen, meta);
1569+
__gfs2_free_blocks(ip, rgd, bstart, (u32)blen, meta);
15701570
(*btotal) += blen;
15711571
gfs2_add_inode_blocks(&ip->i_inode, -blen);
15721572
}
15731573
bstart = bn;
15741574
blen = 1;
15751575
}
15761576
if (bstart) {
1577-
__gfs2_free_blocks(ip, bstart, (u32)blen, meta);
1577+
__gfs2_free_blocks(ip, rgd, bstart, (u32)blen, meta);
15781578
(*btotal) += blen;
15791579
gfs2_add_inode_blocks(&ip->i_inode, -blen);
15801580
}

fs/gfs2/dir.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,8 @@ static int gfs2_dirent_gather(const struct gfs2_dirent *dent,
506506
* For now the most important thing is to check that the various sizes
507507
* are correct.
508508
*/
509-
static int gfs2_check_dirent(struct gfs2_dirent *dent, unsigned int offset,
509+
static int gfs2_check_dirent(struct gfs2_sbd *sdp,
510+
struct gfs2_dirent *dent, unsigned int offset,
510511
unsigned int size, unsigned int len, int first)
511512
{
512513
const char *msg = "gfs2_dirent too small";
@@ -528,12 +529,12 @@ static int gfs2_check_dirent(struct gfs2_dirent *dent, unsigned int offset,
528529
goto error;
529530
return 0;
530531
error:
531-
pr_warn("%s: %s (%s)\n",
532+
fs_warn(sdp, "%s: %s (%s)\n",
532533
__func__, msg, first ? "first in block" : "not first in block");
533534
return -EIO;
534535
}
535536

536-
static int gfs2_dirent_offset(const void *buf)
537+
static int gfs2_dirent_offset(struct gfs2_sbd *sdp, const void *buf)
537538
{
538539
const struct gfs2_meta_header *h = buf;
539540
int offset;
@@ -552,7 +553,8 @@ static int gfs2_dirent_offset(const void *buf)
552553
}
553554
return offset;
554555
wrong_type:
555-
pr_warn("%s: wrong block type %u\n", __func__, be32_to_cpu(h->mh_type));
556+
fs_warn(sdp, "%s: wrong block type %u\n", __func__,
557+
be32_to_cpu(h->mh_type));
556558
return -1;
557559
}
558560

@@ -566,15 +568,15 @@ static struct gfs2_dirent *gfs2_dirent_scan(struct inode *inode, void *buf,
566568
unsigned size;
567569
int ret = 0;
568570

569-
ret = gfs2_dirent_offset(buf);
571+
ret = gfs2_dirent_offset(GFS2_SB(inode), buf);
570572
if (ret < 0)
571573
goto consist_inode;
572574

573575
offset = ret;
574576
prev = NULL;
575577
dent = buf + offset;
576578
size = be16_to_cpu(dent->de_rec_len);
577-
if (gfs2_check_dirent(dent, offset, size, len, 1))
579+
if (gfs2_check_dirent(GFS2_SB(inode), dent, offset, size, len, 1))
578580
goto consist_inode;
579581
do {
580582
ret = scan(dent, name, opaque);
@@ -586,7 +588,8 @@ static struct gfs2_dirent *gfs2_dirent_scan(struct inode *inode, void *buf,
586588
prev = dent;
587589
dent = buf + offset;
588590
size = be16_to_cpu(dent->de_rec_len);
589-
if (gfs2_check_dirent(dent, offset, size, len, 0))
591+
if (gfs2_check_dirent(GFS2_SB(inode), dent, offset, size,
592+
len, 0))
590593
goto consist_inode;
591594
} while(1);
592595

@@ -1043,7 +1046,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
10431046
len = BIT(dip->i_depth - be16_to_cpu(oleaf->lf_depth));
10441047
half_len = len >> 1;
10451048
if (!half_len) {
1046-
pr_warn("i_depth %u lf_depth %u index %u\n",
1049+
fs_warn(GFS2_SB(inode), "i_depth %u lf_depth %u index %u\n",
10471050
dip->i_depth, be16_to_cpu(oleaf->lf_depth), index);
10481051
gfs2_consist_inode(dip);
10491052
error = -EIO;
@@ -1351,7 +1354,7 @@ static int gfs2_set_cookies(struct gfs2_sbd *sdp, struct buffer_head *bh,
13511354
if (!sdp->sd_args.ar_loccookie)
13521355
continue;
13531356
offset = (char *)(darr[i]) -
1354-
(bh->b_data + gfs2_dirent_offset(bh->b_data));
1357+
(bh->b_data + gfs2_dirent_offset(sdp, bh->b_data));
13551358
offset /= GFS2_MIN_DIRENT_SIZE;
13561359
offset += leaf_nr * sdp->sd_max_dents_per_leaf;
13571360
if (offset >= GFS2_USE_HASH_FLAG ||
@@ -2018,7 +2021,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
20182021
l_blocks++;
20192022
}
20202023

2021-
gfs2_rlist_alloc(&rlist, LM_ST_EXCLUSIVE);
2024+
gfs2_rlist_alloc(&rlist);
20222025

20232026
for (x = 0; x < rlist.rl_rgrps; x++) {
20242027
struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(rlist.rl_ghs[x].gh_gl);
@@ -2039,6 +2042,8 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
20392042
bh = leaf_bh;
20402043

20412044
for (blk = leaf_no; blk; blk = nblk) {
2045+
struct gfs2_rgrpd *rgd;
2046+
20422047
if (blk != leaf_no) {
20432048
error = get_leaf(dip, blk, &bh);
20442049
if (error)
@@ -2049,7 +2054,8 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
20492054
if (blk != leaf_no)
20502055
brelse(bh);
20512056

2052-
gfs2_free_meta(dip, blk, 1);
2057+
rgd = gfs2_blk2rgrpd(sdp, blk, true);
2058+
gfs2_free_meta(dip, rgd, blk, 1);
20532059
gfs2_add_inode_blocks(&dip->i_inode, -1);
20542060
}
20552061

fs/gfs2/file.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,17 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
314314
return do_gfs2_set_flags(filp, gfsflags, mask);
315315
}
316316

317+
static int gfs2_getlabel(struct file *filp, char __user *label)
318+
{
319+
struct inode *inode = file_inode(filp);
320+
struct gfs2_sbd *sdp = GFS2_SB(inode);
321+
322+
if (copy_to_user(label, sdp->sd_sb.sb_locktable, GFS2_LOCKNAME_LEN))
323+
return -EFAULT;
324+
325+
return 0;
326+
}
327+
317328
static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
318329
{
319330
switch(cmd) {
@@ -323,7 +334,10 @@ static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
323334
return gfs2_set_flags(filp, (u32 __user *)arg);
324335
case FITRIM:
325336
return gfs2_fitrim(filp, (void __user *)arg);
337+
case FS_IOC_GETFSLABEL:
338+
return gfs2_getlabel(filp, (char __user *)arg);
326339
}
340+
327341
return -ENOTTY;
328342
}
329343

@@ -347,8 +361,8 @@ static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size)
347361
size_t blks = (size + sdp->sd_sb.sb_bsize - 1) >> sdp->sd_sb.sb_bsize_shift;
348362
int hint = min_t(size_t, INT_MAX, blks);
349363

350-
if (hint > atomic_read(&ip->i_res.rs_sizehint))
351-
atomic_set(&ip->i_res.rs_sizehint, hint);
364+
if (hint > atomic_read(&ip->i_sizehint))
365+
atomic_set(&ip->i_sizehint, hint);
352366
}
353367

354368
/**

fs/gfs2/glock.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)
494494
do_xmote(gl, gh, LM_ST_UNLOCKED);
495495
break;
496496
default: /* Everything else */
497-
pr_err("wanted %u got %u\n", gl->gl_target, state);
497+
fs_err(gl->gl_name.ln_sbd, "wanted %u got %u\n",
498+
gl->gl_target, state);
498499
GLOCK_BUG_ON(gl, 1);
499500
}
500501
spin_unlock(&gl->gl_lockref.lock);
@@ -577,7 +578,7 @@ __acquires(&gl->gl_lockref.lock)
577578
gfs2_glock_queue_work(gl, 0);
578579
}
579580
else if (ret) {
580-
pr_err("lm_lock ret %d\n", ret);
581+
fs_err(sdp, "lm_lock ret %d\n", ret);
581582
GLOCK_BUG_ON(gl, !test_bit(SDF_SHUTDOWN,
582583
&sdp->sd_flags));
583584
}
@@ -1064,13 +1065,13 @@ __acquires(&gl->gl_lockref.lock)
10641065
return;
10651066

10661067
trap_recursive:
1067-
pr_err("original: %pSR\n", (void *)gh2->gh_ip);
1068-
pr_err("pid: %d\n", pid_nr(gh2->gh_owner_pid));
1069-
pr_err("lock type: %d req lock state : %d\n",
1068+
fs_err(sdp, "original: %pSR\n", (void *)gh2->gh_ip);
1069+
fs_err(sdp, "pid: %d\n", pid_nr(gh2->gh_owner_pid));
1070+
fs_err(sdp, "lock type: %d req lock state : %d\n",
10701071
gh2->gh_gl->gl_name.ln_type, gh2->gh_state);
1071-
pr_err("new: %pSR\n", (void *)gh->gh_ip);
1072-
pr_err("pid: %d\n", pid_nr(gh->gh_owner_pid));
1073-
pr_err("lock type: %d req lock state : %d\n",
1072+
fs_err(sdp, "new: %pSR\n", (void *)gh->gh_ip);
1073+
fs_err(sdp, "pid: %d\n", pid_nr(gh->gh_owner_pid));
1074+
fs_err(sdp, "lock type: %d req lock state : %d\n",
10741075
gh->gh_gl->gl_name.ln_type, gh->gh_state);
10751076
gfs2_dump_glock(NULL, gl);
10761077
BUG();

fs/gfs2/incore.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct gfs2_bitmap {
9292
unsigned long bi_flags;
9393
u32 bi_offset;
9494
u32 bi_start;
95-
u32 bi_len;
95+
u32 bi_bytes;
9696
u32 bi_blocks;
9797
};
9898

@@ -309,10 +309,6 @@ struct gfs2_qadata { /* quota allocation data */
309309
*/
310310

311311
struct gfs2_blkreserv {
312-
/* components used during write (step 1): */
313-
atomic_t rs_sizehint; /* hint of the write size */
314-
315-
struct gfs2_holder rs_rgd_gh; /* Filled in by get_local_rgrp */
316312
struct rb_node rs_node; /* link to other block reservations */
317313
struct gfs2_rbm rs_rbm; /* Start of reservation */
318314
u32 rs_free; /* how many blocks are still free */
@@ -417,8 +413,10 @@ struct gfs2_inode {
417413
struct gfs2_holder i_iopen_gh;
418414
struct gfs2_holder i_gh; /* for prepare/commit_write only */
419415
struct gfs2_qadata *i_qadata; /* quota allocation data */
416+
struct gfs2_holder i_rgd_gh;
420417
struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */
421418
u64 i_goal; /* goal block for allocations */
419+
atomic_t i_sizehint; /* hint of the write size */
422420
struct rw_semaphore i_rw_mutex;
423421
struct list_head i_ordered;
424422
struct list_head i_trunc_list;
@@ -623,6 +621,7 @@ enum {
623621
SDF_RORECOVERY = 7, /* read only recovery */
624622
SDF_SKIP_DLM_UNLOCK = 8,
625623
SDF_FORCE_AIL_FLUSH = 9,
624+
SDF_AIL1_IO_ERROR = 10,
626625
};
627626

628627
enum gfs2_freeze_state {

fs/gfs2/lock_dlm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ static void gdlm_bast(void *arg, int mode)
177177
gfs2_glock_cb(gl, LM_ST_SHARED);
178178
break;
179179
default:
180-
pr_err("unknown bast mode %d\n", mode);
180+
fs_err(gl->gl_name.ln_sbd, "unknown bast mode %d\n", mode);
181181
BUG();
182182
}
183183
}
184184

185185
/* convert gfs lock-state to dlm lock-mode */
186186

187-
static int make_mode(const unsigned int lmstate)
187+
static int make_mode(struct gfs2_sbd *sdp, const unsigned int lmstate)
188188
{
189189
switch (lmstate) {
190190
case LM_ST_UNLOCKED:
@@ -196,7 +196,7 @@ static int make_mode(const unsigned int lmstate)
196196
case LM_ST_SHARED:
197197
return DLM_LOCK_PR;
198198
}
199-
pr_err("unknown LM state %d\n", lmstate);
199+
fs_err(sdp, "unknown LM state %d\n", lmstate);
200200
BUG();
201201
return -1;
202202
}
@@ -257,7 +257,7 @@ static int gdlm_lock(struct gfs2_glock *gl, unsigned int req_state,
257257
u32 lkf;
258258
char strname[GDLM_STRNAME_BYTES] = "";
259259

260-
req = make_mode(req_state);
260+
req = make_mode(gl->gl_name.ln_sbd, req_state);
261261
lkf = make_flags(gl, flags, req);
262262
gfs2_glstats_inc(gl, GFS2_LKS_DCOUNT);
263263
gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT);
@@ -309,7 +309,7 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
309309
error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK,
310310
NULL, gl);
311311
if (error) {
312-
pr_err("gdlm_unlock %x,%llx err=%d\n",
312+
fs_err(sdp, "gdlm_unlock %x,%llx err=%d\n",
313313
gl->gl_name.ln_type,
314314
(unsigned long long)gl->gl_name.ln_number, error);
315315
return;

fs/gfs2/log.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ __acquires(&sdp->sd_ail_lock)
108108
gfs2_assert(sdp, bd->bd_tr == tr);
109109

110110
if (!buffer_busy(bh)) {
111-
if (!buffer_uptodate(bh)) {
111+
if (!buffer_uptodate(bh) &&
112+
!test_and_set_bit(SDF_AIL1_IO_ERROR,
113+
&sdp->sd_flags)) {
112114
gfs2_io_error_bh(sdp, bh);
113115
*withdraw = true;
114116
}
@@ -206,7 +208,8 @@ static void gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
206208
gfs2_assert(sdp, bd->bd_tr == tr);
207209
if (buffer_busy(bh))
208210
continue;
209-
if (!buffer_uptodate(bh)) {
211+
if (!buffer_uptodate(bh) &&
212+
!test_and_set_bit(SDF_AIL1_IO_ERROR, &sdp->sd_flags)) {
210213
gfs2_io_error_bh(sdp, bh);
211214
*withdraw = true;
212215
}
@@ -618,7 +621,7 @@ void gfs2_write_revokes(struct gfs2_sbd *sdp)
618621

619622
gfs2_ail1_empty(sdp);
620623
spin_lock(&sdp->sd_ail_lock);
621-
list_for_each_entry(tr, &sdp->sd_ail1_list, tr_list) {
624+
list_for_each_entry_reverse(tr, &sdp->sd_ail1_list, tr_list) {
622625
list_for_each_entry(bd, &tr->tr_ail2_list, bd_ail_st_list) {
623626
if (list_empty(&bd->bd_list)) {
624627
have_revokes = 1;
@@ -642,7 +645,7 @@ void gfs2_write_revokes(struct gfs2_sbd *sdp)
642645
}
643646
gfs2_log_lock(sdp);
644647
spin_lock(&sdp->sd_ail_lock);
645-
list_for_each_entry(tr, &sdp->sd_ail1_list, tr_list) {
648+
list_for_each_entry_reverse(tr, &sdp->sd_ail1_list, tr_list) {
646649
list_for_each_entry_safe(bd, tmp, &tr->tr_ail2_list, bd_ail_st_list) {
647650
if (max_revokes == 0)
648651
goto out_of_blocks;

fs/gfs2/lops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void maybe_release_space(struct gfs2_bufdata *bd)
8181
if (sdp->sd_args.ar_discard)
8282
gfs2_rgrp_send_discards(sdp, rgd->rd_data0, bd->bd_bh, bi, 1, NULL);
8383
memcpy(bi->bi_clone + bi->bi_offset,
84-
bd->bd_bh->b_data + bi->bi_offset, bi->bi_len);
84+
bd->bd_bh->b_data + bi->bi_offset, bi->bi_bytes);
8585
clear_bit(GBF_FULL, &bi->bi_flags);
8686
rgd->rd_free_clone = rgd->rd_free;
8787
rgd->rd_extfail_pt = rgd->rd_free;

fs/gfs2/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ static void gfs2_init_inode_once(void *foo)
3939
struct gfs2_inode *ip = foo;
4040

4141
inode_init_once(&ip->i_inode);
42+
atomic_set(&ip->i_sizehint, 0);
4243
init_rwsem(&ip->i_rw_mutex);
4344
INIT_LIST_HEAD(&ip->i_trunc_list);
4445
ip->i_qadata = NULL;
46+
gfs2_holder_mark_uninitialized(&ip->i_rgd_gh);
4547
memset(&ip->i_res, 0, sizeof(ip->i_res));
4648
RB_CLEAR_NODE(&ip->i_res.rs_node);
4749
ip->i_hash_cache = NULL;

fs/gfs2/ops_fstype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
7272
if (!sdp)
7373
return NULL;
7474

75-
sb->s_fs_info = sdp;
7675
sdp->sd_vfs = sb;
7776
sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats);
7877
if (!sdp->sd_lkstats) {
7978
kfree(sdp);
8079
return NULL;
8180
}
81+
sb->s_fs_info = sdp;
8282

8383
set_bit(SDF_NOJOURNALID, &sdp->sd_flags);
8484
gfs2_tune_init(&sdp->sd_tune);

0 commit comments

Comments
 (0)