Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit e0fcc9c

Browse files
committed
Merge tag 'gfs2-v6.3-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2
Pull gfs2 updates from Andreas Gruenbacher: - Fix revoke processing at unmount and on read-only remount - Refuse reading in inodes with an impossible indirect block height - Various minor cleanups * tag 'gfs2-v6.3-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: gfs2: gfs2_ail_empty_gl no log flush on error gfs2: Issue message when revokes cannot be written gfs2: Perform second log flush in gfs2_make_fs_ro gfs2: return errors from gfs2_ail_empty_gl gfs2: Move variable assignment behind a null pointer check in inode_go_dump gfs2: Use gfs2_holder_initialized for jindex gfs2: Eliminate gfs2_trim_blocks gfs2: Fix inode height consistency check gfs2: Remove ghs[] from gfs2_unlink gfs2: Remove ghs[] from gfs2_link gfs2: Remove duplicate i_nlink check from gfs2_link()
2 parents 85d7ab2 + 644f6bf commit e0fcc9c

File tree

6 files changed

+49
-48
lines changed

6 files changed

+49
-48
lines changed

fs/gfs2/bmap.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,14 +2035,6 @@ static int do_shrink(struct inode *inode, u64 newsize)
20352035
return error;
20362036
}
20372037

2038-
void gfs2_trim_blocks(struct inode *inode)
2039-
{
2040-
int ret;
2041-
2042-
ret = do_shrink(inode, inode->i_size);
2043-
WARN_ON(ret != 0);
2044-
}
2045-
20462038
/**
20472039
* do_grow - Touch and update inode size
20482040
* @inode: The inode

fs/gfs2/bmap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ extern int gfs2_get_extent(struct inode *inode, u64 lblock, u64 *dblock,
5858
extern int gfs2_alloc_extent(struct inode *inode, u64 lblock, u64 *dblock,
5959
unsigned *extlen, bool *new);
6060
extern int gfs2_setattr_size(struct inode *inode, u64 size);
61-
extern void gfs2_trim_blocks(struct inode *inode);
6261
extern int gfs2_truncatei_resume(struct gfs2_inode *ip);
6362
extern int gfs2_file_dealloc(struct gfs2_inode *ip);
6463
extern int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,

fs/gfs2/glops.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int gfs2_ail_empty_gl(struct gfs2_glock *gl)
9090
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
9191
struct gfs2_trans tr;
9292
unsigned int revokes;
93-
int ret;
93+
int ret = 0;
9494

9595
revokes = atomic_read(&gl->gl_ail_count);
9696

@@ -124,15 +124,18 @@ static int gfs2_ail_empty_gl(struct gfs2_glock *gl)
124124
memset(&tr, 0, sizeof(tr));
125125
set_bit(TR_ONSTACK, &tr.tr_flags);
126126
ret = __gfs2_trans_begin(&tr, sdp, 0, revokes, _RET_IP_);
127-
if (ret)
127+
if (ret) {
128+
fs_err(sdp, "Transaction error %d: Unable to write revokes.", ret);
128129
goto flush;
130+
}
129131
__gfs2_ail_flush(gl, 0, revokes);
130132
gfs2_trans_end(sdp);
131133

132134
flush:
133-
gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL |
134-
GFS2_LFC_AIL_EMPTY_GL);
135-
return 0;
135+
if (!ret)
136+
gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL |
137+
GFS2_LFC_AIL_EMPTY_GL);
138+
return ret;
136139
}
137140

138141
void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
@@ -326,7 +329,9 @@ static int inode_go_sync(struct gfs2_glock *gl)
326329
ret = gfs2_inode_metasync(gl);
327330
if (!error)
328331
error = ret;
329-
gfs2_ail_empty_gl(gl);
332+
ret = gfs2_ail_empty_gl(gl);
333+
if (!error)
334+
error = ret;
330335
/*
331336
* Writeback of the data mapping may cause the dirty flag to be set
332337
* so we have to clear it again here.
@@ -396,6 +401,7 @@ static int inode_go_demote_ok(const struct gfs2_glock *gl)
396401

397402
static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
398403
{
404+
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
399405
const struct gfs2_dinode *str = buf;
400406
struct timespec64 atime;
401407
u16 height, depth;
@@ -442,7 +448,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
442448
/* i_diskflags and i_eattr must be set before gfs2_set_inode_flags() */
443449
gfs2_set_inode_flags(inode);
444450
height = be16_to_cpu(str->di_height);
445-
if (unlikely(height > GFS2_MAX_META_HEIGHT))
451+
if (unlikely(height > sdp->sd_max_height))
446452
goto corrupt;
447453
ip->i_height = (u8)height;
448454

@@ -534,12 +540,13 @@ static void inode_go_dump(struct seq_file *seq, struct gfs2_glock *gl,
534540
const char *fs_id_buf)
535541
{
536542
struct gfs2_inode *ip = gl->gl_object;
537-
struct inode *inode = &ip->i_inode;
543+
struct inode *inode;
538544
unsigned long nrpages;
539545

540546
if (ip == NULL)
541547
return;
542548

549+
inode = &ip->i_inode;
543550
xa_lock_irq(&inode->i_data.i_pages);
544551
nrpages = inode->i_data.nrpages;
545552
xa_unlock_irq(&inode->i_data.i_pages);

fs/gfs2/inode.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
941941
struct gfs2_sbd *sdp = GFS2_SB(dir);
942942
struct inode *inode = d_inode(old_dentry);
943943
struct gfs2_inode *ip = GFS2_I(inode);
944-
struct gfs2_holder ghs[2];
944+
struct gfs2_holder d_gh, gh;
945945
struct buffer_head *dibh;
946946
struct gfs2_diradd da = { .bh = NULL, .save_loc = 1, };
947947
int error;
@@ -953,14 +953,14 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
953953
if (error)
954954
return error;
955955

956-
gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
957-
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
956+
gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, &d_gh);
957+
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
958958

959-
error = gfs2_glock_nq(ghs); /* parent */
959+
error = gfs2_glock_nq(&d_gh);
960960
if (error)
961961
goto out_parent;
962962

963-
error = gfs2_glock_nq(ghs + 1); /* child */
963+
error = gfs2_glock_nq(&gh);
964964
if (error)
965965
goto out_child;
966966

@@ -992,9 +992,6 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
992992
error = -EPERM;
993993
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
994994
goto out_gunlock;
995-
error = -EINVAL;
996-
if (!ip->i_inode.i_nlink)
997-
goto out_gunlock;
998995
error = -EMLINK;
999996
if (ip->i_inode.i_nlink == (u32)-1)
1000997
goto out_gunlock;
@@ -1049,13 +1046,13 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
10491046
gfs2_quota_unlock(dip);
10501047
out_gunlock:
10511048
gfs2_dir_no_add(&da);
1052-
gfs2_glock_dq(ghs + 1);
1049+
gfs2_glock_dq(&gh);
10531050
out_child:
1054-
gfs2_glock_dq(ghs);
1051+
gfs2_glock_dq(&d_gh);
10551052
out_parent:
10561053
gfs2_qa_put(dip);
1057-
gfs2_holder_uninit(ghs);
1058-
gfs2_holder_uninit(ghs + 1);
1054+
gfs2_holder_uninit(&d_gh);
1055+
gfs2_holder_uninit(&gh);
10591056
return error;
10601057
}
10611058

@@ -1146,7 +1143,7 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
11461143
struct gfs2_sbd *sdp = GFS2_SB(dir);
11471144
struct inode *inode = d_inode(dentry);
11481145
struct gfs2_inode *ip = GFS2_I(inode);
1149-
struct gfs2_holder ghs[3];
1146+
struct gfs2_holder d_gh, r_gh, gh;
11501147
struct gfs2_rgrpd *rgd;
11511148
int error;
11521149

@@ -1156,21 +1153,21 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
11561153

11571154
error = -EROFS;
11581155

1159-
gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
1160-
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
1156+
gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, &d_gh);
1157+
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
11611158

11621159
rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
11631160
if (!rgd)
11641161
goto out_inodes;
11651162

1166-
gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, LM_FLAG_NODE_SCOPE, ghs + 2);
1163+
gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, LM_FLAG_NODE_SCOPE, &r_gh);
11671164

11681165

1169-
error = gfs2_glock_nq(ghs); /* parent */
1166+
error = gfs2_glock_nq(&d_gh);
11701167
if (error)
11711168
goto out_parent;
11721169

1173-
error = gfs2_glock_nq(ghs + 1); /* child */
1170+
error = gfs2_glock_nq(&gh);
11741171
if (error)
11751172
goto out_child;
11761173

@@ -1184,7 +1181,7 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
11841181
goto out_rgrp;
11851182
}
11861183

1187-
error = gfs2_glock_nq(ghs + 2); /* rgrp */
1184+
error = gfs2_glock_nq(&r_gh); /* rgrp */
11881185
if (error)
11891186
goto out_rgrp;
11901187

@@ -1200,16 +1197,16 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
12001197
gfs2_trans_end(sdp);
12011198

12021199
out_gunlock:
1203-
gfs2_glock_dq(ghs + 2);
1200+
gfs2_glock_dq(&r_gh);
12041201
out_rgrp:
1205-
gfs2_glock_dq(ghs + 1);
1202+
gfs2_glock_dq(&gh);
12061203
out_child:
1207-
gfs2_glock_dq(ghs);
1204+
gfs2_glock_dq(&d_gh);
12081205
out_parent:
1209-
gfs2_holder_uninit(ghs + 2);
1206+
gfs2_holder_uninit(&r_gh);
12101207
out_inodes:
1211-
gfs2_holder_uninit(ghs + 1);
1212-
gfs2_holder_uninit(ghs);
1208+
gfs2_holder_uninit(&gh);
1209+
gfs2_holder_uninit(&d_gh);
12131210
return error;
12141211
}
12151212

fs/gfs2/ops_fstype.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,13 +734,11 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
734734
struct inode *master = d_inode(sdp->sd_master_dir);
735735
struct gfs2_holder ji_gh;
736736
struct gfs2_inode *ip;
737-
int jindex = 1;
738737
int error = 0;
739738

740-
if (undo) {
741-
jindex = 0;
739+
gfs2_holder_mark_uninitialized(&ji_gh);
740+
if (undo)
742741
goto fail_statfs;
743-
}
744742

745743
sdp->sd_jindex = gfs2_lookup_simple(master, "jindex");
746744
if (IS_ERR(sdp->sd_jindex)) {
@@ -852,7 +850,6 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
852850
sdp->sd_log_idle = 1;
853851
set_bit(SDF_JOURNAL_CHECKED, &sdp->sd_flags);
854852
gfs2_glock_dq_uninit(&ji_gh);
855-
jindex = 0;
856853
INIT_WORK(&sdp->sd_freeze_work, gfs2_freeze_func);
857854
return 0;
858855

@@ -869,7 +866,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
869866
gfs2_glock_dq_uninit(&sdp->sd_journal_gh);
870867
fail_jindex:
871868
gfs2_jindex_free(sdp);
872-
if (jindex)
869+
if (gfs2_holder_initialized(&ji_gh))
873870
gfs2_glock_dq_uninit(&ji_gh);
874871
fail:
875872
iput(sdp->sd_jindex);

fs/gfs2/super.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,15 @@ void gfs2_make_fs_ro(struct gfs2_sbd *sdp)
552552
gfs2_quota_sync(sdp->sd_vfs, 0);
553553
gfs2_statfs_sync(sdp->sd_vfs, 0);
554554

555+
/* We do two log flushes here. The first one commits dirty inodes
556+
* and rgrps to the journal, but queues up revokes to the ail list.
557+
* The second flush writes out and removes the revokes.
558+
*
559+
* The first must be done before the FLUSH_SHUTDOWN code
560+
* clears the LIVE flag, otherwise it will not be able to start
561+
* a transaction to write its revokes, and the error will cause
562+
* a withdraw of the file system. */
563+
gfs2_log_flush(sdp, NULL, GFS2_LFC_MAKE_FS_RO);
555564
gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_SHUTDOWN |
556565
GFS2_LFC_MAKE_FS_RO);
557566
wait_event_timeout(sdp->sd_log_waitq,

0 commit comments

Comments
 (0)