Skip to content

Commit bf2d636

Browse files
committed
Merge tag 'gfs2-v5.8-rc3.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2
Pull gfs2 fixes from Andreas Gruenbacher: "Various gfs2 fixes" * tag 'gfs2-v5.8-rc3.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: gfs2: The freeze glock should never be frozen gfs2: When freezing gfs2, use GL_EXACT and not GL_NOCACHE gfs2: read-only mounts should grab the sd_freeze_gl glock gfs2: freeze should work on read-only mounts gfs2: eliminate GIF_ORDERED in favor of list_empty gfs2: Don't sleep during glock hash walk gfs2: fix trans slab error when withdraw occurs inside log_flush gfs2: Don't return NULL from gfs2_inode_lookup
2 parents 1d42871 + c860f8f commit bf2d636

File tree

10 files changed

+58
-28
lines changed

10 files changed

+58
-28
lines changed

fs/gfs2/glock.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,10 @@ bool gfs2_delete_work_queued(const struct gfs2_glock *gl)
18991899

19001900
static void flush_delete_work(struct gfs2_glock *gl)
19011901
{
1902-
flush_delayed_work(&gl->gl_delete);
1902+
if (cancel_delayed_work(&gl->gl_delete)) {
1903+
queue_delayed_work(gfs2_delete_workqueue,
1904+
&gl->gl_delete, 0);
1905+
}
19031906
gfs2_glock_queue_work(gl, 0);
19041907
}
19051908

fs/gfs2/glops.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,7 @@ static int freeze_go_sync(struct gfs2_glock *gl)
531531
int error = 0;
532532
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
533533

534-
if (gl->gl_state == LM_ST_SHARED && !gfs2_withdrawn(sdp) &&
535-
test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
534+
if (gl->gl_req == LM_ST_EXCLUSIVE && !gfs2_withdrawn(sdp)) {
536535
atomic_set(&sdp->sd_freeze_state, SFS_STARTING_FREEZE);
537536
error = freeze_super(sdp->sd_vfs);
538537
if (error) {
@@ -545,8 +544,11 @@ static int freeze_go_sync(struct gfs2_glock *gl)
545544
gfs2_assert_withdraw(sdp, 0);
546545
}
547546
queue_work(gfs2_freeze_wq, &sdp->sd_freeze_work);
548-
gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_FREEZE |
549-
GFS2_LFC_FREEZE_GO_SYNC);
547+
if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags))
548+
gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_FREEZE |
549+
GFS2_LFC_FREEZE_GO_SYNC);
550+
else /* read-only mounts */
551+
atomic_set(&sdp->sd_freeze_state, SFS_FROZEN);
550552
}
551553
return 0;
552554
}

fs/gfs2/incore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ enum {
399399
GIF_QD_LOCKED = 1,
400400
GIF_ALLOC_FAILED = 2,
401401
GIF_SW_PAGED = 3,
402-
GIF_ORDERED = 4,
403402
GIF_FREE_VFS_INODE = 5,
404403
GIF_GLOP_PENDING = 6,
405404
GIF_DEFERRED_DELETE = 7,

fs/gfs2/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,11 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
207207

208208
if (no_formal_ino && ip->i_no_formal_ino &&
209209
no_formal_ino != ip->i_no_formal_ino) {
210+
error = -ESTALE;
210211
if (inode->i_state & I_NEW)
211212
goto fail;
212213
iput(inode);
213-
return ERR_PTR(-ESTALE);
214+
return ERR_PTR(error);
214215
}
215216

216217
if (inode->i_state & I_NEW)

fs/gfs2/log.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,12 @@ static int ip_cmp(void *priv, struct list_head *a, struct list_head *b)
613613
return 0;
614614
}
615615

616+
static void __ordered_del_inode(struct gfs2_inode *ip)
617+
{
618+
if (!list_empty(&ip->i_ordered))
619+
list_del_init(&ip->i_ordered);
620+
}
621+
616622
static void gfs2_ordered_write(struct gfs2_sbd *sdp)
617623
{
618624
struct gfs2_inode *ip;
@@ -623,8 +629,7 @@ static void gfs2_ordered_write(struct gfs2_sbd *sdp)
623629
while (!list_empty(&sdp->sd_log_ordered)) {
624630
ip = list_first_entry(&sdp->sd_log_ordered, struct gfs2_inode, i_ordered);
625631
if (ip->i_inode.i_mapping->nrpages == 0) {
626-
test_and_clear_bit(GIF_ORDERED, &ip->i_flags);
627-
list_del(&ip->i_ordered);
632+
__ordered_del_inode(ip);
628633
continue;
629634
}
630635
list_move(&ip->i_ordered, &written);
@@ -643,8 +648,7 @@ static void gfs2_ordered_wait(struct gfs2_sbd *sdp)
643648
spin_lock(&sdp->sd_ordered_lock);
644649
while (!list_empty(&sdp->sd_log_ordered)) {
645650
ip = list_first_entry(&sdp->sd_log_ordered, struct gfs2_inode, i_ordered);
646-
list_del(&ip->i_ordered);
647-
WARN_ON(!test_and_clear_bit(GIF_ORDERED, &ip->i_flags));
651+
__ordered_del_inode(ip);
648652
if (ip->i_inode.i_mapping->nrpages == 0)
649653
continue;
650654
spin_unlock(&sdp->sd_ordered_lock);
@@ -659,8 +663,7 @@ void gfs2_ordered_del_inode(struct gfs2_inode *ip)
659663
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
660664

661665
spin_lock(&sdp->sd_ordered_lock);
662-
if (test_and_clear_bit(GIF_ORDERED, &ip->i_flags))
663-
list_del(&ip->i_ordered);
666+
__ordered_del_inode(ip);
664667
spin_unlock(&sdp->sd_ordered_lock);
665668
}
666669

@@ -1002,6 +1005,16 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
10021005

10031006
out:
10041007
if (gfs2_withdrawn(sdp)) {
1008+
/**
1009+
* If the tr_list is empty, we're withdrawing during a log
1010+
* flush that targets a transaction, but the transaction was
1011+
* never queued onto any of the ail lists. Here we add it to
1012+
* ail1 just so that ail_drain() will find and free it.
1013+
*/
1014+
spin_lock(&sdp->sd_ail_lock);
1015+
if (tr && list_empty(&tr->tr_list))
1016+
list_add(&tr->tr_list, &sdp->sd_ail1_list);
1017+
spin_unlock(&sdp->sd_ail_lock);
10051018
ail_drain(sdp); /* frees all transactions */
10061019
tr = NULL;
10071020
}

fs/gfs2/log.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
5353
if (gfs2_is_jdata(ip) || !gfs2_is_ordered(sdp))
5454
return;
5555

56-
if (!test_bit(GIF_ORDERED, &ip->i_flags)) {
56+
if (list_empty(&ip->i_ordered)) {
5757
spin_lock(&sdp->sd_ordered_lock);
58-
if (!test_and_set_bit(GIF_ORDERED, &ip->i_flags))
58+
if (list_empty(&ip->i_ordered))
5959
list_add(&ip->i_ordered, &sdp->sd_log_ordered);
6060
spin_unlock(&sdp->sd_ordered_lock);
6161
}

fs/gfs2/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static void gfs2_init_inode_once(void *foo)
3939
atomic_set(&ip->i_sizehint, 0);
4040
init_rwsem(&ip->i_rw_mutex);
4141
INIT_LIST_HEAD(&ip->i_trunc_list);
42+
INIT_LIST_HEAD(&ip->i_ordered);
4243
ip->i_qadata = NULL;
4344
gfs2_holder_mark_uninitialized(&ip->i_rgd_gh);
4445
memset(&ip->i_res, 0, sizeof(ip->i_res));

fs/gfs2/ops_fstype.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,18 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
11361136
goto fail_per_node;
11371137
}
11381138

1139-
if (!sb_rdonly(sb)) {
1139+
if (sb_rdonly(sb)) {
1140+
struct gfs2_holder freeze_gh;
1141+
1142+
error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED,
1143+
LM_FLAG_NOEXP | GL_EXACT,
1144+
&freeze_gh);
1145+
if (error) {
1146+
fs_err(sdp, "can't make FS RO: %d\n", error);
1147+
goto fail_per_node;
1148+
}
1149+
gfs2_glock_dq_uninit(&freeze_gh);
1150+
} else {
11401151
error = gfs2_make_fs_rw(sdp);
11411152
if (error) {
11421153
fs_err(sdp, "can't make FS RW: %d\n", error);

fs/gfs2/recovery.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ void gfs2_recover_func(struct work_struct *work)
364364
/* Acquire a shared hold on the freeze lock */
365365

366366
error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED,
367-
LM_FLAG_NOEXP | LM_FLAG_PRIORITY,
368-
&thaw_gh);
367+
LM_FLAG_NOEXP | LM_FLAG_PRIORITY |
368+
GL_EXACT, &thaw_gh);
369369
if (error)
370370
goto fail_gunlock_ji;
371371

fs/gfs2/super.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
167167
if (error)
168168
return error;
169169

170-
error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED, 0,
170+
error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED,
171+
LM_FLAG_NOEXP | GL_EXACT,
171172
&freeze_gh);
172173
if (error)
173174
goto fail_threads;
@@ -203,7 +204,6 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
203204
return 0;
204205

205206
fail:
206-
freeze_gh.gh_flags |= GL_NOCACHE;
207207
gfs2_glock_dq_uninit(&freeze_gh);
208208
fail_threads:
209209
if (sdp->sd_quotad_process)
@@ -430,7 +430,7 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp)
430430
}
431431

432432
error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_EXCLUSIVE,
433-
GL_NOCACHE, &sdp->sd_freeze_gh);
433+
LM_FLAG_NOEXP, &sdp->sd_freeze_gh);
434434
if (error)
435435
goto out;
436436

@@ -613,13 +613,15 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
613613
!gfs2_glock_is_locked_by_me(sdp->sd_freeze_gl)) {
614614
if (!log_write_allowed) {
615615
error = gfs2_glock_nq_init(sdp->sd_freeze_gl,
616-
LM_ST_SHARED, GL_NOCACHE |
617-
LM_FLAG_TRY, &freeze_gh);
616+
LM_ST_SHARED, LM_FLAG_TRY |
617+
LM_FLAG_NOEXP | GL_EXACT,
618+
&freeze_gh);
618619
if (error == GLR_TRYFAILED)
619620
error = 0;
620621
} else {
621622
error = gfs2_glock_nq_init(sdp->sd_freeze_gl,
622-
LM_ST_SHARED, GL_NOCACHE,
623+
LM_ST_SHARED,
624+
LM_FLAG_NOEXP | GL_EXACT,
623625
&freeze_gh);
624626
if (error && !gfs2_withdrawn(sdp))
625627
return error;
@@ -761,8 +763,8 @@ void gfs2_freeze_func(struct work_struct *work)
761763
struct super_block *sb = sdp->sd_vfs;
762764

763765
atomic_inc(&sb->s_active);
764-
error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED, 0,
765-
&freeze_gh);
766+
error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED,
767+
LM_FLAG_NOEXP | GL_EXACT, &freeze_gh);
766768
if (error) {
767769
fs_info(sdp, "GFS2: couldn't get freeze lock : %d\n", error);
768770
gfs2_assert_withdraw(sdp, 0);
@@ -774,8 +776,6 @@ void gfs2_freeze_func(struct work_struct *work)
774776
error);
775777
gfs2_assert_withdraw(sdp, 0);
776778
}
777-
if (!test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags))
778-
freeze_gh.gh_flags |= GL_NOCACHE;
779779
gfs2_glock_dq_uninit(&freeze_gh);
780780
}
781781
deactivate_super(sb);

0 commit comments

Comments
 (0)