diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2018-08-30 11:01:50 -0400 |
---|---|---|
committer | Bob Peterson <rpeterso@redhat.com> | 2018-10-12 08:29:14 -0400 |
commit | 21f09c4395c95dfaa0598d20d41cb2a669e1967e (patch) | |
tree | 997637a5fd6f19f1f0a149970ff55b6872d4c0f2 | |
parent | 3548fce1645bafbeb2256caaa3635a21bafd1621 (diff) |
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>
-rw-r--r-- | fs/gfs2/file.c | 4 | ||||
-rw-r--r-- | fs/gfs2/incore.h | 6 | ||||
-rw-r--r-- | fs/gfs2/main.c | 2 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 16 |
4 files changed, 13 insertions, 15 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 6510f4e07d0e..45a17b770d97 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -361,8 +361,8 @@ static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size) | |||
361 | size_t blks = (size + sdp->sd_sb.sb_bsize - 1) >> sdp->sd_sb.sb_bsize_shift; | 361 | size_t blks = (size + sdp->sd_sb.sb_bsize - 1) >> sdp->sd_sb.sb_bsize_shift; |
362 | int hint = min_t(size_t, INT_MAX, blks); | 362 | int hint = min_t(size_t, INT_MAX, blks); |
363 | 363 | ||
364 | if (hint > atomic_read(&ip->i_res.rs_sizehint)) | 364 | if (hint > atomic_read(&ip->i_sizehint)) |
365 | atomic_set(&ip->i_res.rs_sizehint, hint); | 365 | atomic_set(&ip->i_sizehint, hint); |
366 | } | 366 | } |
367 | 367 | ||
368 | /** | 368 | /** |
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 5d72e8b66a26..997a3a19f77d 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -309,10 +309,6 @@ struct gfs2_qadata { /* quota allocation data */ | |||
309 | */ | 309 | */ |
310 | 310 | ||
311 | struct gfs2_blkreserv { | 311 | struct gfs2_blkreserv { |
312 | /* components used during write (step 1): */ | ||
313 | atomic_t rs_sizehint; /* hint of the write size */ | ||
314 | |||
315 | struct gfs2_holder rs_rgd_gh; /* Filled in by get_local_rgrp */ | ||
316 | struct rb_node rs_node; /* link to other block reservations */ | 312 | struct rb_node rs_node; /* link to other block reservations */ |
317 | struct gfs2_rbm rs_rbm; /* Start of reservation */ | 313 | struct gfs2_rbm rs_rbm; /* Start of reservation */ |
318 | u32 rs_free; /* how many blocks are still free */ | 314 | u32 rs_free; /* how many blocks are still free */ |
@@ -417,8 +413,10 @@ struct gfs2_inode { | |||
417 | struct gfs2_holder i_iopen_gh; | 413 | struct gfs2_holder i_iopen_gh; |
418 | struct gfs2_holder i_gh; /* for prepare/commit_write only */ | 414 | struct gfs2_holder i_gh; /* for prepare/commit_write only */ |
419 | struct gfs2_qadata *i_qadata; /* quota allocation data */ | 415 | struct gfs2_qadata *i_qadata; /* quota allocation data */ |
416 | struct gfs2_holder i_rgd_gh; | ||
420 | struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */ | 417 | struct gfs2_blkreserv i_res; /* rgrp multi-block reservation */ |
421 | u64 i_goal; /* goal block for allocations */ | 418 | u64 i_goal; /* goal block for allocations */ |
419 | atomic_t i_sizehint; /* hint of the write size */ | ||
422 | struct rw_semaphore i_rw_mutex; | 420 | struct rw_semaphore i_rw_mutex; |
423 | struct list_head i_ordered; | 421 | struct list_head i_ordered; |
424 | struct list_head i_trunc_list; | 422 | struct list_head i_trunc_list; |
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 2d55e2c3333c..c7603063f861 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c | |||
@@ -39,9 +39,11 @@ static void gfs2_init_inode_once(void *foo) | |||
39 | struct gfs2_inode *ip = foo; | 39 | struct gfs2_inode *ip = foo; |
40 | 40 | ||
41 | inode_init_once(&ip->i_inode); | 41 | inode_init_once(&ip->i_inode); |
42 | atomic_set(&ip->i_sizehint, 0); | ||
42 | init_rwsem(&ip->i_rw_mutex); | 43 | init_rwsem(&ip->i_rw_mutex); |
43 | INIT_LIST_HEAD(&ip->i_trunc_list); | 44 | INIT_LIST_HEAD(&ip->i_trunc_list); |
44 | ip->i_qadata = NULL; | 45 | ip->i_qadata = NULL; |
46 | gfs2_holder_mark_uninitialized(&ip->i_rgd_gh); | ||
45 | memset(&ip->i_res, 0, sizeof(ip->i_res)); | 47 | memset(&ip->i_res, 0, sizeof(ip->i_res)); |
46 | RB_CLEAR_NODE(&ip->i_res.rs_node); | 48 | RB_CLEAR_NODE(&ip->i_res.rs_node); |
47 | ip->i_hash_cache = NULL; | 49 | ip->i_hash_cache = NULL; |
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 6eb2addcbff5..3b17a4e77b39 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -1565,7 +1565,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip, | |||
1565 | if (S_ISDIR(inode->i_mode)) | 1565 | if (S_ISDIR(inode->i_mode)) |
1566 | extlen = 1; | 1566 | extlen = 1; |
1567 | else { | 1567 | else { |
1568 | extlen = max_t(u32, atomic_read(&rs->rs_sizehint), ap->target); | 1568 | extlen = max_t(u32, atomic_read(&ip->i_sizehint), ap->target); |
1569 | extlen = clamp(extlen, RGRP_RSRV_MINBLKS, free_blocks); | 1569 | extlen = clamp(extlen, RGRP_RSRV_MINBLKS, free_blocks); |
1570 | } | 1570 | } |
1571 | if ((rgd->rd_free_clone < rgd->rd_reserved) || (free_blocks < extlen)) | 1571 | 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) | |||
2077 | } | 2077 | } |
2078 | error = gfs2_glock_nq_init(rs->rs_rbm.rgd->rd_gl, | 2078 | error = gfs2_glock_nq_init(rs->rs_rbm.rgd->rd_gl, |
2079 | LM_ST_EXCLUSIVE, flags, | 2079 | LM_ST_EXCLUSIVE, flags, |
2080 | &rs->rs_rgd_gh); | 2080 | &ip->i_rgd_gh); |
2081 | if (unlikely(error)) | 2081 | if (unlikely(error)) |
2082 | return error; | 2082 | return error; |
2083 | if (!gfs2_rs_active(rs) && (loops < 2) && | 2083 | if (!gfs2_rs_active(rs) && (loops < 2) && |
@@ -2086,7 +2086,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap) | |||
2086 | if (sdp->sd_args.ar_rgrplvb) { | 2086 | if (sdp->sd_args.ar_rgrplvb) { |
2087 | error = update_rgrp_lvb(rs->rs_rbm.rgd); | 2087 | error = update_rgrp_lvb(rs->rs_rbm.rgd); |
2088 | if (unlikely(error)) { | 2088 | if (unlikely(error)) { |
2089 | gfs2_glock_dq_uninit(&rs->rs_rgd_gh); | 2089 | gfs2_glock_dq_uninit(&ip->i_rgd_gh); |
2090 | return error; | 2090 | return error; |
2091 | } | 2091 | } |
2092 | } | 2092 | } |
@@ -2129,7 +2129,7 @@ skip_rgrp: | |||
2129 | 2129 | ||
2130 | /* Unlock rgrp if required */ | 2130 | /* Unlock rgrp if required */ |
2131 | if (!rg_locked) | 2131 | if (!rg_locked) |
2132 | gfs2_glock_dq_uninit(&rs->rs_rgd_gh); | 2132 | gfs2_glock_dq_uninit(&ip->i_rgd_gh); |
2133 | next_rgrp: | 2133 | next_rgrp: |
2134 | /* Find the next rgrp, and continue looking */ | 2134 | /* Find the next rgrp, and continue looking */ |
2135 | if (gfs2_select_rgrp(&rs->rs_rbm.rgd, begin)) | 2135 | if (gfs2_select_rgrp(&rs->rs_rbm.rgd, begin)) |
@@ -2166,10 +2166,8 @@ next_rgrp: | |||
2166 | 2166 | ||
2167 | void gfs2_inplace_release(struct gfs2_inode *ip) | 2167 | void gfs2_inplace_release(struct gfs2_inode *ip) |
2168 | { | 2168 | { |
2169 | struct gfs2_blkreserv *rs = &ip->i_res; | 2169 | if (gfs2_holder_initialized(&ip->i_rgd_gh)) |
2170 | 2170 | gfs2_glock_dq_uninit(&ip->i_rgd_gh); | |
2171 | if (gfs2_holder_initialized(&rs->rs_rgd_gh)) | ||
2172 | gfs2_glock_dq_uninit(&rs->rs_rgd_gh); | ||
2173 | } | 2171 | } |
2174 | 2172 | ||
2175 | /** | 2173 | /** |
@@ -2328,7 +2326,7 @@ static void gfs2_adjust_reservation(struct gfs2_inode *ip, | |||
2328 | goto out; | 2326 | goto out; |
2329 | /* We used up our block reservation, so we should | 2327 | /* We used up our block reservation, so we should |
2330 | reserve more blocks next time. */ | 2328 | reserve more blocks next time. */ |
2331 | atomic_add(RGRP_RSRV_ADDBLKS, &rs->rs_sizehint); | 2329 | atomic_add(RGRP_RSRV_ADDBLKS, &ip->i_sizehint); |
2332 | } | 2330 | } |
2333 | __rs_deltree(rs); | 2331 | __rs_deltree(rs); |
2334 | } | 2332 | } |