Commit b09e593d authored by Steven Whitehouse's avatar Steven Whitehouse
Browse files

[GFS2] Fix a ref count bug and other clean ups



This fixes a ref count bug that sometimes showed up a umount time
(causing it to hang) but it otherwise mostly harmless. At the same
time there are some clean ups including making the log operations
structures const, moving a memory allocation so that its not done
in the fast path of checking to see if there is an outstanding
transaction related to a particular glock.

Removes the sd_log_wrap varaible which was updated, but never actually
used anywhere. Updates the gfs2 ioctl() to run without the kernel lock
(which it never needed anyway). Removes the "invalidate inodes" loop
from GFS2's put_super routine. This is done in kill super anyway so
we don't need to do it here. The loop was also bogus in that if there
are any inodes "stuck" at this point its a bug and we need to know
about it rather than hide it by hanging forever.

Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent 55eccc6d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ int gfs2_logd(void *data)
		gfs2_ail1_empty(sdp, DIO_ALL);

		if (time_after_eq(jiffies, t)) {
			gfs2_log_flush(sdp);
			gfs2_log_flush(sdp, NULL);
			sdp->sd_log_flush_time = jiffies;
		}

+2 −0
Original line number Diff line number Diff line
@@ -789,6 +789,8 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode,
	if (error)
		return ERR_PTR(error);
	dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, scan, name, NULL);
	brelse(bh);

got_dent:
	*pbh = bh;
	return dent;
+3 −3
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static void meta_go_sync(struct gfs2_glock *gl, int flags)
		return;

	if (test_and_clear_bit(GLF_DIRTY, &gl->gl_flags)) {
		gfs2_log_flush_glock(gl);
		gfs2_log_flush(gl->gl_sbd, gl);
		gfs2_meta_sync(gl, flags | DIO_START | DIO_WAIT);
		if (flags & DIO_RELEASE)
			gfs2_ail_empty_gl(gl);
@@ -149,12 +149,12 @@ static void inode_go_sync(struct gfs2_glock *gl, int flags)
	if (test_bit(GLF_DIRTY, &gl->gl_flags)) {
		if (meta && data) {
			gfs2_page_sync(gl, flags | DIO_START);
			gfs2_log_flush_glock(gl);
			gfs2_log_flush(gl->gl_sbd, gl);
			gfs2_meta_sync(gl, flags | DIO_START | DIO_WAIT);
			gfs2_page_sync(gl, flags | DIO_WAIT);
			clear_bit(GLF_DIRTY, &gl->gl_flags);
		} else if (meta) {
			gfs2_log_flush_glock(gl);
			gfs2_log_flush(gl->gl_sbd, gl);
			gfs2_meta_sync(gl, flags | DIO_START | DIO_WAIT);
		} else if (data)
			gfs2_page_sync(gl, flags | DIO_START | DIO_WAIT);
+3 −3
Original line number Diff line number Diff line
@@ -62,12 +62,12 @@ struct gfs2_log_operations {
				 struct gfs2_log_descriptor *ld, __be64 *ptr,
				 int pass);
	void (*lo_after_scan) (struct gfs2_jdesc *jd, int error, int pass);
	char *lo_name;
	const char *lo_name;
};

struct gfs2_log_element {
	struct list_head le_list;
	struct gfs2_log_operations *le_ops;
	const struct gfs2_log_operations *le_ops;
};

struct gfs2_bitmap {
@@ -618,6 +618,7 @@ struct gfs2_sbd {
	unsigned int sd_log_num_rg;
	unsigned int sd_log_num_databuf;
	unsigned int sd_log_num_jdata;
	unsigned int sd_log_num_hdrs;

	struct list_head sd_log_le_gl;
	struct list_head sd_log_le_buf;
@@ -631,7 +632,6 @@ struct gfs2_sbd {
	uint64_t sd_log_sequence;
	unsigned int sd_log_head;
	unsigned int sd_log_tail;
	uint64_t sd_log_wraps;
	int sd_log_idle;

	unsigned long sd_log_flush_time;
+18 −15
Original line number Diff line number Diff line
@@ -171,13 +171,14 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)
	while(sdp->sd_log_blks_free <= blks) {
		gfs2_log_unlock(sdp);
		gfs2_ail1_empty(sdp, 0);
		gfs2_log_flush(sdp);
		gfs2_log_flush(sdp, NULL);

		if (try++)
			gfs2_ail1_start(sdp, 0);
		gfs2_log_lock(sdp);
	}
	sdp->sd_log_blks_free -= blks;
	/* printk(KERN_INFO "reserved %u blocks (%u left)\n", blks, sdp->sd_log_blks_free); */
	gfs2_log_unlock(sdp);
	mutex_unlock(&sdp->sd_log_reserve_mutex);

@@ -199,6 +200,7 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks)

	gfs2_log_lock(sdp);
	sdp->sd_log_blks_free += blks;
	/* printk(KERN_INFO "released %u blocks (%u left)\n", blks, sdp->sd_log_blks_free); */
	gfs2_assert_withdraw(sdp,
			     sdp->sd_log_blks_free <= sdp->sd_jdesc->jd_blocks);
	gfs2_log_unlock(sdp);
@@ -342,6 +344,7 @@ static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail, int pull)

	gfs2_log_lock(sdp);
	sdp->sd_log_blks_free += dist - ((pull) ? 1 : 0);
	/* printk(KERN_INFO "pull tail refunding %u blocks (%u left) pull=%d\n", dist - ((pull) ? 1 : 0), sdp->sd_log_blks_free, pull); */
	gfs2_assert_withdraw(sdp,
			     sdp->sd_log_blks_free <= sdp->sd_jdesc->jd_blocks);
	gfs2_log_unlock(sdp);
@@ -364,6 +367,8 @@ static void log_write_header(struct gfs2_sbd *sdp, uint32_t flags, int pull)
	unsigned int tail;
	uint32_t hash;

	/* printk(KERN_INFO "log write header start (flags=%08x, pull=%d)\n", flags, pull); */

	bh = sb_getblk(sdp->sd_vfs, blkno);
	lock_buffer(bh);
	memset(bh->b_data, 0, bh->b_size);
@@ -398,6 +403,8 @@ static void log_write_header(struct gfs2_sbd *sdp, uint32_t flags, int pull)

	sdp->sd_log_idle = (tail == sdp->sd_log_flush_head);
	log_incr_head(sdp);

	/* printk(KERN_INFO "log write header out\n"); */
}

static void log_flush_commit(struct gfs2_sbd *sdp)
@@ -432,20 +439,16 @@ static void log_flush_commit(struct gfs2_sbd *sdp)
}

/**
 * gfs2_log_flush_i - flush incore transaction(s)
 * gfs2_log_flush - flush incore transaction(s)
 * @sdp: the filesystem
 * @gl: The glock structure to flush.  If NULL, flush the whole incore log
 *
 */

void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
{
	struct gfs2_ail *ai;

	ai = kzalloc(sizeof(struct gfs2_ail), GFP_NOFS | __GFP_NOFAIL);
	INIT_LIST_HEAD(&ai->ai_ail1_list);
	INIT_LIST_HEAD(&ai->ai_ail2_list);

	down_write(&sdp->sd_log_flush_lock);

	if (gl) {
@@ -453,12 +456,14 @@ void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
		if (list_empty(&gl->gl_le.le_list)) {
			gfs2_log_unlock(sdp);
			up_write(&sdp->sd_log_flush_lock);
			kfree(ai);
			return;
		}
		gfs2_log_unlock(sdp);
	}

	ai = kzalloc(sizeof(struct gfs2_ail), GFP_NOFS | __GFP_NOFAIL);
	INIT_LIST_HEAD(&ai->ai_ail1_list);
	INIT_LIST_HEAD(&ai->ai_ail2_list);

	gfs2_assert_withdraw(sdp,
			sdp->sd_log_num_buf == sdp->sd_log_commited_buf);
@@ -476,11 +481,12 @@ void gfs2_log_flush_i(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
		log_write_header(sdp, 0, PULL);
	lops_after_commit(sdp, ai);
	sdp->sd_log_head = sdp->sd_log_flush_head;
	if (sdp->sd_log_flush_wrapped)
		sdp->sd_log_wraps++;

	/* printk(KERN_INFO "sd_log_num_hdrs %u\n", sdp->sd_log_num_hdrs); */

	sdp->sd_log_blks_reserved =
		sdp->sd_log_commited_buf =
		sdp->sd_log_num_hdrs = 
		sdp->sd_log_commited_revoke = 0;

	gfs2_log_lock(sdp);
@@ -519,8 +525,7 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
	sdp->sd_log_blks_free += tr->tr_reserved -
				 (reserved - sdp->sd_log_blks_reserved);

	gfs2_assert_withdraw(sdp,
			     sdp->sd_log_blks_free >= old);
	gfs2_assert_withdraw(sdp, sdp->sd_log_blks_free >= old);
	gfs2_assert_withdraw(sdp,
			     sdp->sd_log_blks_free <= sdp->sd_jdesc->jd_blocks);

@@ -548,7 +553,7 @@ void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
	gfs2_log_lock(sdp);
	if (sdp->sd_log_num_buf > gfs2_tune_get(sdp, gt_incore_log_blocks)) {
		gfs2_log_unlock(sdp);
		gfs2_log_flush(sdp);
		gfs2_log_flush(sdp, NULL);
	} else
		gfs2_log_unlock(sdp);
}
@@ -583,8 +588,6 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp)
	gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail2_list));

	sdp->sd_log_head = sdp->sd_log_flush_head;
	if (sdp->sd_log_flush_wrapped)
		sdp->sd_log_wraps++;
	sdp->sd_log_tail = sdp->sd_log_head;

	up_write(&sdp->sd_log_flush_lock);
Loading