From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Peterson Date: Wed, 10 Jan 2018 13:42:22 -0700 Subject: [Cluster-devel] [GFS2 PATCH 1/6] GFS2: Simplify gfs2_rgrp_used_recently In-Reply-To: <20180110204227.20315-1-rpeterso@redhat.com> References: <20180110204227.20315-1-rpeterso@redhat.com> Message-ID: <20180110204227.20315-2-rpeterso@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit This patch simplifies function gfs2_rgrp_used_recently. Now it uses ktime functions to do its calculations. Also, it's called with the rgrp rather than the reservation, and the constant HZ rather than the hard-coded value 1000. Signed-off-by: Bob Peterson --- fs/gfs2/rgrp.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index e8aba6fa1472..ea95d7c70e23 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -1893,21 +1893,18 @@ static bool gfs2_rgrp_congested(const struct gfs2_rgrpd *rgd, int loops) } /** - * gfs2_rgrp_used_recently - * @rs: The block reservation with the rgrp to test + * gfs2_rgrp_used_recently - check if a rgrp has been used recently + * @rgd: The rgrp to test * @msecs: The time limit in milliseconds * * Returns: True if the rgrp glock has been used within the time limit */ -static bool gfs2_rgrp_used_recently(const struct gfs2_blkreserv *rs, - u64 msecs) +static inline bool gfs2_rgrp_used_recently(const struct gfs2_rgrpd *rgd, + u64 msecs) { - u64 tdiff; - - tdiff = ktime_to_ns(ktime_sub(ktime_get_real(), - rs->rs_rbm.rgd->rd_gl->gl_dstamp)); - - return tdiff > (msecs * 1000 * 1000); + return (ktime_before(ktime_get_real(), + ktime_add(rgd->rd_gl->gl_dstamp, + ms_to_ktime(msecs)))); } static u32 gfs2_orlov_skip(const struct gfs2_inode *ip) @@ -2007,7 +2004,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, struct gfs2_alloc_parms *ap) !fast_to_acquire(rs->rs_rbm.rgd)) goto next_rgrp; if ((loops < 2) && - gfs2_rgrp_used_recently(rs, 1000) && + gfs2_rgrp_used_recently(rs->rs_rbm.rgd, HZ) && gfs2_rgrp_congested(rs->rs_rbm.rgd, loops)) goto next_rgrp; } -- 2.14.3