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

Commit 7b9cff46 authored by Steven Whitehouse's avatar Steven Whitehouse
Browse files

GFS2: Add allocation parameters structure



This patch adds a structure to contain allocation parameters with
the intention of future expansion of this structure. The idea is
that we should be able to add more information about the allocation
in the future in order to allow the allocator to make a better job
of placing the requests on-disk.

There is no functional difference from applying this patch.

Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent af5c2697
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -611,12 +611,14 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
		gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);
		gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);


	if (alloc_required) {
	if (alloc_required) {
		struct gfs2_alloc_parms ap = { .aflags = 0, };
		error = gfs2_quota_lock_check(ip);
		error = gfs2_quota_lock_check(ip);
		if (error)
		if (error)
			goto out_unlock;
			goto out_unlock;


		requested = data_blocks + ind_blocks;
		requested = data_blocks + ind_blocks;
		error = gfs2_inplace_reserve(ip, requested, 0);
		ap.target = requested;
		error = gfs2_inplace_reserve(ip, &ap);
		if (error)
		if (error)
			goto out_qunlock;
			goto out_qunlock;
	}
	}
+2 −1
Original line number Original line Diff line number Diff line
@@ -1216,6 +1216,7 @@ static int do_grow(struct inode *inode, u64 size)
{
{
	struct gfs2_inode *ip = GFS2_I(inode);
	struct gfs2_inode *ip = GFS2_I(inode);
	struct gfs2_sbd *sdp = GFS2_SB(inode);
	struct gfs2_sbd *sdp = GFS2_SB(inode);
	struct gfs2_alloc_parms ap = { .target = 1, };
	struct buffer_head *dibh;
	struct buffer_head *dibh;
	int error;
	int error;
	int unstuff = 0;
	int unstuff = 0;
@@ -1226,7 +1227,7 @@ static int do_grow(struct inode *inode, u64 size)
		if (error)
		if (error)
			return error;
			return error;


		error = gfs2_inplace_reserve(ip, 1, 0);
		error = gfs2_inplace_reserve(ip, &ap);
		if (error)
		if (error)
			goto do_grow_qunlock;
			goto do_grow_qunlock;
		unstuff = 1;
		unstuff = 1;
+6 −2
Original line number Original line Diff line number Diff line
@@ -383,6 +383,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
	struct inode *inode = file_inode(vma->vm_file);
	struct inode *inode = file_inode(vma->vm_file);
	struct gfs2_inode *ip = GFS2_I(inode);
	struct gfs2_inode *ip = GFS2_I(inode);
	struct gfs2_sbd *sdp = GFS2_SB(inode);
	struct gfs2_sbd *sdp = GFS2_SB(inode);
	struct gfs2_alloc_parms ap = { .aflags = 0, };
	unsigned long last_index;
	unsigned long last_index;
	u64 pos = page->index << PAGE_CACHE_SHIFT;
	u64 pos = page->index << PAGE_CACHE_SHIFT;
	unsigned int data_blocks, ind_blocks, rblocks;
	unsigned int data_blocks, ind_blocks, rblocks;
@@ -430,7 +431,8 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
	if (ret)
	if (ret)
		goto out_unlock;
		goto out_unlock;
	gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks);
	gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks);
	ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks, 0);
	ap.target = data_blocks + ind_blocks;
	ret = gfs2_inplace_reserve(ip, &ap);
	if (ret)
	if (ret)
		goto out_quota_unlock;
		goto out_quota_unlock;


@@ -800,6 +802,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
	struct inode *inode = file_inode(file);
	struct inode *inode = file_inode(file);
	struct gfs2_sbd *sdp = GFS2_SB(inode);
	struct gfs2_sbd *sdp = GFS2_SB(inode);
	struct gfs2_inode *ip = GFS2_I(inode);
	struct gfs2_inode *ip = GFS2_I(inode);
	struct gfs2_alloc_parms ap = { .aflags = 0, };
	unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
	unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
	loff_t bytes, max_bytes;
	loff_t bytes, max_bytes;
	int error;
	int error;
@@ -850,7 +853,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
retry:
retry:
		gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);
		gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);


		error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks, 0);
		ap.target = data_blocks + ind_blocks;
		error = gfs2_inplace_reserve(ip, &ap);
		if (error) {
		if (error) {
			if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) {
			if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) {
				bytes >>= 1;
				bytes >>= 1;
+14 −0
Original line number Original line Diff line number Diff line
@@ -285,6 +285,20 @@ struct gfs2_blkreserv {
	unsigned int rs_qa_qd_num;
	unsigned int rs_qa_qd_num;
};
};


/*
 * Allocation parameters
 * @target: The number of blocks we'd ideally like to allocate
 * @aflags: The flags (e.g. Orlov flag)
 *
 * The intent is to gradually expand this structure over time in
 * order to give more information, e.g. alignment, min extent size
 * to the allocation code.
 */
struct gfs2_alloc_parms {
	u32 target;
	u32 aflags;
};

enum {
enum {
	GLF_LOCK			= 1,
	GLF_LOCK			= 1,
	GLF_DEMOTE			= 3,
	GLF_DEMOTE			= 3,
+8 −4
Original line number Original line Diff line number Diff line
@@ -379,6 +379,7 @@ static void munge_mode_uid_gid(const struct gfs2_inode *dip,
static int alloc_dinode(struct gfs2_inode *ip, u32 flags)
static int alloc_dinode(struct gfs2_inode *ip, u32 flags)
{
{
	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
	struct gfs2_alloc_parms ap = { .target = RES_DINODE, .aflags = flags, };
	int error;
	int error;
	int dblocks = 1;
	int dblocks = 1;


@@ -386,7 +387,7 @@ static int alloc_dinode(struct gfs2_inode *ip, u32 flags)
	if (error)
	if (error)
		goto out;
		goto out;


	error = gfs2_inplace_reserve(ip, RES_DINODE, flags);
	error = gfs2_inplace_reserve(ip, &ap);
	if (error)
	if (error)
		goto out_quota;
		goto out_quota;


@@ -472,6 +473,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
		       struct gfs2_inode *ip, int arq)
		       struct gfs2_inode *ip, int arq)
{
{
	struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
	struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
	struct gfs2_alloc_parms ap = { .target = sdp->sd_max_dirres, };
	int error;
	int error;


	if (arq) {
	if (arq) {
@@ -479,7 +481,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
		if (error)
		if (error)
			goto fail_quota_locks;
			goto fail_quota_locks;


		error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres, 0);
		error = gfs2_inplace_reserve(dip, &ap);
		if (error)
		if (error)
			goto fail_quota_locks;
			goto fail_quota_locks;


@@ -874,11 +876,12 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
	error = 0;
	error = 0;


	if (alloc_required) {
	if (alloc_required) {
		struct gfs2_alloc_parms ap = { .target = sdp->sd_max_dirres, };
		error = gfs2_quota_lock_check(dip);
		error = gfs2_quota_lock_check(dip);
		if (error)
		if (error)
			goto out_gunlock;
			goto out_gunlock;


		error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres, 0);
		error = gfs2_inplace_reserve(dip, &ap);
		if (error)
		if (error)
			goto out_gunlock_q;
			goto out_gunlock_q;


@@ -1387,11 +1390,12 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
		goto out_gunlock;
		goto out_gunlock;


	if (alloc_required) {
	if (alloc_required) {
		struct gfs2_alloc_parms ap = { .target = sdp->sd_max_dirres, };
		error = gfs2_quota_lock_check(ndip);
		error = gfs2_quota_lock_check(ndip);
		if (error)
		if (error)
			goto out_gunlock;
			goto out_gunlock;


		error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres, 0);
		error = gfs2_inplace_reserve(ndip, &ap);
		if (error)
		if (error)
			goto out_gunlock_q;
			goto out_gunlock_q;


Loading