gfs2: Move rs_{sizehint, rgd_gh} fields into the inode

Move the rs_sizehint and rs_rgd_gh fields from struct gfs2_blkreserv
into the inode: they are more closely related to the inode than to a
particular reservation.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Reviewed-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
Andreas Gruenbacher 2018-08-30 16:01:50 +01:00 коммит произвёл Bob Peterson
Родитель 3548fce164
Коммит 21f09c4395
4 изменённых файлов: 13 добавлений и 15 удалений

Просмотреть файл

@ -361,8 +361,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; 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); int hint = min_t(size_t, INT_MAX, blks);
if (hint > atomic_read(&ip->i_res.rs_sizehint)) if (hint > atomic_read(&ip->i_sizehint))
atomic_set(&ip->i_res.rs_sizehint, hint); atomic_set(&ip->i_sizehint, hint);
} }
/** /**

Просмотреть файл

@ -309,10 +309,6 @@ struct gfs2_qadata { /* quota allocation data */
*/ */
struct gfs2_blkreserv { struct gfs2_blkreserv {
/* components used during write (step 1): */
atomic_t rs_sizehint; /* hint of the write size */
struct gfs2_holder rs_rgd_gh; /* Filled in by get_local_rgrp */
struct rb_node rs_node; /* link to other block reservations */ struct rb_node rs_node; /* link to other block reservations */
struct gfs2_rbm rs_rbm; /* Start of reservation */ struct gfs2_rbm rs_rbm; /* Start of reservation */
u32 rs_free; /* how many blocks are still free */ u32 rs_free; /* how many blocks are still free */
@ -417,8 +413,10 @@ struct gfs2_inode {
struct gfs2_holder i_iopen_gh; struct gfs2_holder i_iopen_gh;
struct gfs2_holder i_gh; /* for prepare/commit_write only */ struct gfs2_holder i_gh; /* for prepare/commit_write only */
struct gfs2_qadata *i_qadata; /* quota allocation data */ struct gfs2_qadata *i_qadata; /* quota allocation data */
struct gfs2_holder i_rgd_gh;
struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */ struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */
u64 i_goal; /* goal block for allocations */ u64 i_goal; /* goal block for allocations */
atomic_t i_sizehint; /* hint of the write size */
struct rw_semaphore i_rw_mutex; struct rw_semaphore i_rw_mutex;
struct list_head i_ordered; struct list_head i_ordered;
struct list_head i_trunc_list; struct list_head i_trunc_list;

Просмотреть файл

@ -39,9 +39,11 @@ static void gfs2_init_inode_once(void *foo)
struct gfs2_inode *ip = foo; struct gfs2_inode *ip = foo;
inode_init_once(&ip->i_inode); inode_init_once(&ip->i_inode);
atomic_set(&ip->i_sizehint, 0);
init_rwsem(&ip->i_rw_mutex); init_rwsem(&ip->i_rw_mutex);
INIT_LIST_HEAD(&ip->i_trunc_list); INIT_LIST_HEAD(&ip->i_trunc_list);
ip->i_qadata = NULL; ip->i_qadata = NULL;
gfs2_holder_mark_uninitialized(&ip->i_rgd_gh);
memset(&ip->i_res, 0, sizeof(ip->i_res)); memset(&ip->i_res, 0, sizeof(ip->i_res));
RB_CLEAR_NODE(&ip->i_res.rs_node); RB_CLEAR_NODE(&ip->i_res.rs_node);
ip->i_hash_cache = NULL; ip->i_hash_cache = NULL;

Просмотреть файл

@ -1565,7 +1565,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
extlen = 1; extlen = 1;
else { else {
extlen = max_t(u32, atomic_read(&rs->rs_sizehint), ap->target); extlen = max_t(u32, atomic_read(&ip->i_sizehint), ap->target);
extlen = clamp(extlen, RGRP_RSRV_MINBLKS, free_blocks); extlen = clamp(extlen, RGRP_RSRV_MINBLKS, free_blocks);
} }
if ((rgd->rd_free_clone < rgd->rd_reserved) || (free_blocks < extlen)) if ((rgd->rd_free_clone < rgd->rd_reserved) || (free_blocks < extlen))
@ -2077,7 +2077,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap)
} }
error = gfs2_glock_nq_init(rs->rs_rbm.rgd->rd_gl, error = gfs2_glock_nq_init(rs->rs_rbm.rgd->rd_gl,
LM_ST_EXCLUSIVE, flags, LM_ST_EXCLUSIVE, flags,
&rs->rs_rgd_gh); &ip->i_rgd_gh);
if (unlikely(error)) if (unlikely(error))
return error; return error;
if (!gfs2_rs_active(rs) && (loops < 2) && if (!gfs2_rs_active(rs) && (loops < 2) &&
@ -2086,7 +2086,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap)
if (sdp->sd_args.ar_rgrplvb) { if (sdp->sd_args.ar_rgrplvb) {
error = update_rgrp_lvb(rs->rs_rbm.rgd); error = update_rgrp_lvb(rs->rs_rbm.rgd);
if (unlikely(error)) { if (unlikely(error)) {
gfs2_glock_dq_uninit(&rs->rs_rgd_gh); gfs2_glock_dq_uninit(&ip->i_rgd_gh);
return error; return error;
} }
} }
@ -2129,7 +2129,7 @@ skip_rgrp:
/* Unlock rgrp if required */ /* Unlock rgrp if required */
if (!rg_locked) if (!rg_locked)
gfs2_glock_dq_uninit(&rs->rs_rgd_gh); gfs2_glock_dq_uninit(&ip->i_rgd_gh);
next_rgrp: next_rgrp:
/* Find the next rgrp, and continue looking */ /* Find the next rgrp, and continue looking */
if (gfs2_select_rgrp(&rs->rs_rbm.rgd, begin)) if (gfs2_select_rgrp(&rs->rs_rbm.rgd, begin))
@ -2166,10 +2166,8 @@ next_rgrp:
void gfs2_inplace_release(struct gfs2_inode *ip) void gfs2_inplace_release(struct gfs2_inode *ip)
{ {
struct gfs2_blkreserv *rs = &ip->i_res; if (gfs2_holder_initialized(&ip->i_rgd_gh))
gfs2_glock_dq_uninit(&ip->i_rgd_gh);
if (gfs2_holder_initialized(&rs->rs_rgd_gh))
gfs2_glock_dq_uninit(&rs->rs_rgd_gh);
} }
/** /**
@ -2328,7 +2326,7 @@ static void gfs2_adjust_reservation(struct gfs2_inode *ip,
goto out; goto out;
/* We used up our block reservation, so we should /* We used up our block reservation, so we should
reserve more blocks next time. */ reserve more blocks next time. */
atomic_add(RGRP_RSRV_ADDBLKS, &rs->rs_sizehint); atomic_add(RGRP_RSRV_ADDBLKS, &ip->i_sizehint);
} }
__rs_deltree(rs); __rs_deltree(rs);
} }