Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a097dc7e authored by Bob Peterson's avatar Bob Peterson
Browse files

GFS2: Make rgrp reservations part of the gfs2_inode structure



Before this patch, multi-block reservation structures were allocated
from a special slab. This patch folds the structure into the gfs2_inode
structure. The disadvantage is that the gfs2_inode needs more memory,
even when a file is opened read-only. The advantages are: (a) we don't
need the special slab and the extra time it takes to allocate and
deallocate from it. (b) we no longer need to worry that the structure
exists for things like quota management. (c) This also allows us to
remove the calls to get_write_access and put_write_access since we
know the structure will exist.

Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
parent b54e9a0b
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -787,8 +787,8 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
	if (error)
		goto out_rlist;

	if (gfs2_rs_active(ip->i_res)) /* needs to be done with the rgrp glock held */
		gfs2_rs_deltree(ip->i_res);
	if (gfs2_rs_active(&ip->i_res)) /* needs to be done with the rgrp glock held */
		gfs2_rs_deltree(&ip->i_res);

	error = gfs2_trans_begin(sdp, rg_blocks + RES_DINODE +
				 RES_INDIRECT + RES_STATFS + RES_QUOTA,
@@ -1291,10 +1291,6 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
	if (ret)
		return ret;

	ret = get_write_access(inode);
	if (ret)
		return ret;

	inode_dio_wait(inode);

	ret = gfs2_rsqa_alloc(ip);
@@ -1307,10 +1303,9 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
		goto out;
	}

	gfs2_rs_deltree(ip->i_res);
	ret = do_shrink(inode, oldsize, newsize);
out:
	put_write_access(inode);
	gfs2_rsqa_delete(ip, NULL);
	return ret;
}

+5 −10
Original line number Diff line number Diff line
@@ -336,8 +336,8 @@ static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size)
	size_t blks = (size + sdp->sd_sb.sb_bsize - 1) >> sdp->sd_sb.sb_bsize_shift;
	int hint = min_t(size_t, INT_MAX, blks);

	if (hint > atomic_read(&ip->i_res->rs_sizehint))
		atomic_set(&ip->i_res->rs_sizehint, hint);
	if (hint > atomic_read(&ip->i_res.rs_sizehint))
		atomic_set(&ip->i_res.rs_sizehint, hint);
}

/**
@@ -397,13 +397,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
	/* Update file times before taking page lock */
	file_update_time(vma->vm_file);

	ret = get_write_access(inode);
	if (ret)
		goto out;

	ret = gfs2_rsqa_alloc(ip);
	if (ret)
		goto out_write_access;
		goto out;

	gfs2_size_hint(vma->vm_file, pos, PAGE_CACHE_SIZE);

@@ -486,8 +482,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
		set_page_dirty(page);
		wait_for_stable_page(page);
	}
out_write_access:
	put_write_access(inode);
out:
	sb_end_pagefault(inode->i_sb);
	return block_page_mkwrite_return(ret);
@@ -944,7 +938,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t le

	ret = __gfs2_fallocate(file, mode, offset, len);
	if (ret)
		gfs2_rs_deltree(ip->i_res);
		gfs2_rs_deltree(&ip->i_res);

out_putw:
	put_write_access(inode);
out_unlock:
+1 −1
Original line number Diff line number Diff line
@@ -394,7 +394,7 @@ struct gfs2_inode {
	struct gfs2_holder i_iopen_gh;
	struct gfs2_holder i_gh; /* for prepare/commit_write only */
	struct gfs2_qadata *i_qadata; /* quota allocation data */
	struct gfs2_blkreserv *i_res; /* rgrp multi-block reservation */
	struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */
	struct gfs2_rgrpd *i_rgd;
	u64 i_goal;	/* goal block for allocations */
	struct rw_semaphore i_rw_mutex;
+0 −5
Original line number Diff line number Diff line
@@ -1859,10 +1859,6 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
	if (!(attr->ia_valid & ATTR_GID) || gid_eq(ogid, ngid))
		ogid = ngid = NO_GID_QUOTA_CHANGE;

	error = get_write_access(inode);
	if (error)
		return error;

	error = gfs2_rsqa_alloc(ip);
	if (error)
		goto out;
@@ -1903,7 +1899,6 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
out_gunlock_q:
	gfs2_quota_unlock(ip);
out:
	put_write_access(inode);
	return error;
}

+2 −11
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ static void gfs2_init_inode_once(void *foo)
	init_rwsem(&ip->i_rw_mutex);
	INIT_LIST_HEAD(&ip->i_trunc_list);
	ip->i_qadata = NULL;
	ip->i_res = NULL;
	memset(&ip->i_res, 0, sizeof(ip->i_res));
	RB_CLEAR_NODE(&ip->i_res.rs_node);
	ip->i_hash_cache = NULL;
}

@@ -142,12 +143,6 @@ static int __init init_gfs2_fs(void)
	if (!gfs2_qadata_cachep)
		goto fail;

	gfs2_rsrv_cachep = kmem_cache_create("gfs2_mblk",
					     sizeof(struct gfs2_blkreserv),
					       0, 0, NULL);
	if (!gfs2_rsrv_cachep)
		goto fail;

	register_shrinker(&gfs2_qd_shrinker);

	error = register_filesystem(&gfs2_fs_type);
@@ -200,9 +195,6 @@ static int __init init_gfs2_fs(void)
	unregister_shrinker(&gfs2_qd_shrinker);
	gfs2_glock_exit();

	if (gfs2_rsrv_cachep)
		kmem_cache_destroy(gfs2_rsrv_cachep);

	if (gfs2_qadata_cachep)
		kmem_cache_destroy(gfs2_qadata_cachep);

@@ -248,7 +240,6 @@ static void __exit exit_gfs2_fs(void)
	rcu_barrier();

	mempool_destroy(gfs2_page_pool);
	kmem_cache_destroy(gfs2_rsrv_cachep);
	kmem_cache_destroy(gfs2_qadata_cachep);
	kmem_cache_destroy(gfs2_quotad_cachep);
	kmem_cache_destroy(gfs2_rgrpd_cachep);
Loading