Skip to content

Commit dcc42d5

Browse files
author
Andreas Gruenbacher
committed
Revert "gfs2: Force withdraw to replay journals and wait for it to finish" (6/6)
The current withdraw code duplicates the journal recovery code gfs2 already has for dealing with node failures, and it does so poorly. That code was added because when releasing a lockspace, we didn't have a way to indicate that the lockspace needs recovery. We now do have this feature, so the current withdraw code can be removed almost entirely. This is one of several steps towards that. Reverts parts of commit 601ef0d ("gfs2: Force withdraw to replay journals and wait for it to finish"). Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 4060581 commit dcc42d5

1 file changed

Lines changed: 3 additions & 124 deletions

File tree

fs/gfs2/util.c

Lines changed: 3 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -115,30 +115,14 @@ void gfs2_freeze_unlock(struct gfs2_sbd *sdp)
115115
gfs2_glock_dq_uninit(&sdp->sd_freeze_gh);
116116
}
117117

118-
static void signal_our_withdraw(struct gfs2_sbd *sdp)
118+
static void do_withdraw(struct gfs2_sbd *sdp)
119119
{
120-
struct gfs2_glock *live_gl = sdp->sd_live_gh.gh_gl;
121-
struct inode *inode;
122-
struct gfs2_inode *ip;
123-
struct gfs2_glock *i_gl;
124-
u64 no_formal_ino;
125-
int ret = 0;
126-
int tries;
127-
128-
if (test_bit(SDF_NORECOVERY, &sdp->sd_flags) || !sdp->sd_jdesc)
129-
return;
130-
131120
gfs2_ail_drain(sdp); /* frees all transactions */
132-
inode = sdp->sd_jdesc->jd_inode;
133-
ip = GFS2_I(inode);
134-
i_gl = ip->i_gl;
135-
no_formal_ino = ip->i_no_formal_ino;
136121

137122
/*
138123
* Don't tell dlm we're bailing until we have no more buffers in the
139124
* wind. If journal had an IO error, the log code should just purge
140-
* the outstanding buffers rather than submitting new IO. Making the
141-
* file system read-only will flush the journal, etc.
125+
* the outstanding buffers rather than submitting new IO.
142126
*
143127
* During a normal unmount, gfs2_make_fs_ro calls gfs2_log_shutdown
144128
* which clears SDF_JOURNAL_LIVE. In a withdraw, we must not write
@@ -168,112 +152,7 @@ static void signal_our_withdraw(struct gfs2_sbd *sdp)
168152
gfs2_gl_dq_holders(sdp);
169153
}
170154

171-
if (sdp->sd_lockstruct.ls_ops->lm_lock == NULL) { /* lock_nolock */
172-
if (!ret)
173-
ret = -EIO;
174-
goto skip_recovery;
175-
}
176-
/*
177-
* Drop the glock for our journal so another node can recover it.
178-
*/
179-
if (gfs2_holder_initialized(&sdp->sd_journal_gh)) {
180-
gfs2_glock_dq_wait(&sdp->sd_journal_gh);
181-
gfs2_holder_uninit(&sdp->sd_journal_gh);
182-
}
183-
sdp->sd_jinode_gh.gh_flags |= GL_NOCACHE;
184-
gfs2_glock_dq(&sdp->sd_jinode_gh);
185155
gfs2_thaw_freeze_initiator(sdp->sd_vfs);
186-
wait_on_bit(&i_gl->gl_flags, GLF_DEMOTE, TASK_UNINTERRUPTIBLE);
187-
188-
/*
189-
* holder_uninit to force glock_put, to force dlm to let go
190-
*/
191-
gfs2_holder_uninit(&sdp->sd_jinode_gh);
192-
193-
/*
194-
* Note: We need to be careful here:
195-
* Our iput of jd_inode will evict it. The evict will dequeue its
196-
* glock, but the glock dq will wait for the withdraw unless we have
197-
* exception code in glock_dq.
198-
*/
199-
iput(inode);
200-
sdp->sd_jdesc->jd_inode = NULL;
201-
/*
202-
* Dequeue the "live" glock, but keep a reference so it's never freed.
203-
*/
204-
gfs2_glock_hold(live_gl);
205-
gfs2_glock_dq_wait(&sdp->sd_live_gh);
206-
/*
207-
* We enqueue the "live" glock in EX so that all other nodes
208-
* get a demote request and act on it. We don't really want the
209-
* lock in EX, so we send a "try" lock with 1CB to produce a callback.
210-
*/
211-
fs_warn(sdp, "Requesting recovery of jid %d.\n",
212-
sdp->sd_lockstruct.ls_jid);
213-
gfs2_holder_reinit(LM_ST_EXCLUSIVE,
214-
LM_FLAG_TRY_1CB | LM_FLAG_RECOVER | GL_NOPID,
215-
&sdp->sd_live_gh);
216-
msleep(GL_GLOCK_MAX_HOLD);
217-
/*
218-
* This will likely fail in a cluster, but succeed standalone:
219-
*/
220-
ret = gfs2_glock_nq(&sdp->sd_live_gh);
221-
222-
gfs2_glock_put(live_gl); /* drop extra reference we acquired */
223-
224-
/*
225-
* If we actually got the "live" lock in EX mode, there are no other
226-
* nodes available to replay our journal.
227-
*/
228-
if (ret == 0) {
229-
fs_warn(sdp, "No other mounters found.\n");
230-
/*
231-
* We are about to release the lockspace. By keeping live_gl
232-
* locked here, we ensure that the next mounter coming along
233-
* will be a "first" mounter which will perform recovery.
234-
*/
235-
goto skip_recovery;
236-
}
237-
238-
/*
239-
* At this point our journal is evicted, so we need to get a new inode
240-
* for it. Once done, we need to call gfs2_find_jhead which
241-
* calls gfs2_map_journal_extents to map it for us again.
242-
*
243-
* Note that we don't really want it to look up a FREE block. The
244-
* GFS2_BLKST_FREE simply overrides a block check in gfs2_inode_lookup
245-
* which would otherwise fail because it requires grabbing an rgrp
246-
* glock, which would fail with -EIO because we're withdrawing.
247-
*/
248-
inode = gfs2_inode_lookup(sdp->sd_vfs, DT_UNKNOWN,
249-
sdp->sd_jdesc->jd_no_addr, no_formal_ino,
250-
GFS2_BLKST_FREE);
251-
if (IS_ERR(inode)) {
252-
fs_warn(sdp, "Reprocessing of jid %d failed with %ld.\n",
253-
sdp->sd_lockstruct.ls_jid, PTR_ERR(inode));
254-
goto skip_recovery;
255-
}
256-
sdp->sd_jdesc->jd_inode = inode;
257-
d_mark_dontcache(inode);
258-
259-
/*
260-
* Now wait until recovery is complete.
261-
*/
262-
for (tries = 0; tries < 10; tries++) {
263-
ret = check_journal_clean(sdp, sdp->sd_jdesc, false);
264-
if (!ret)
265-
break;
266-
msleep(HZ);
267-
fs_warn(sdp, "Waiting for journal recovery jid %d.\n",
268-
sdp->sd_lockstruct.ls_jid);
269-
}
270-
skip_recovery:
271-
if (!ret)
272-
fs_warn(sdp, "Journal recovery complete for jid %d.\n",
273-
sdp->sd_lockstruct.ls_jid);
274-
else
275-
fs_warn(sdp, "Journal recovery skipped for jid %d until next "
276-
"mount.\n", sdp->sd_lockstruct.ls_jid);
277156
}
278157

279158
void gfs2_lm(struct gfs2_sbd *sdp, const char *fmt, ...)
@@ -303,7 +182,7 @@ void gfs2_withdraw_func(struct work_struct *work)
303182

304183
BUG_ON(sdp->sd_args.ar_debug);
305184

306-
signal_our_withdraw(sdp);
185+
do_withdraw(sdp);
307186

308187
kobject_uevent(&sdp->sd_kobj, KOBJ_OFFLINE);
309188

0 commit comments

Comments
 (0)