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

Commit 97ba375b authored by Peng Tao's avatar Peng Tao Committed by Trond Myklebust
Browse files

pnfs/flexfiles: report layoutstat regularly



As a simple scheme, report every minute if IO is still going on.

Reviewed-by: default avatarJeff Layton <jeff.layton@primarydata.com>
Signed-off-by: default avatarPeng Tao <tao.peng@primarydata.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 1bfe3b25
Loading
Loading
Loading
Loading
+23 −4
Original line number Original line Diff line number Diff line
@@ -452,14 +452,23 @@ nfs4_ff_layout_calc_completion_time(struct rpc_task *task)
	return ktime_sub(ktime_get(), task->tk_start);
	return ktime_sub(ktime_get(), task->tk_start);
}
}


static void
static bool
nfs4_ff_layoutstat_start_io(struct nfs4_ff_layout_mirror *mirror,
nfs4_ff_layoutstat_start_io(struct nfs4_ff_layout_mirror *mirror,
			    struct nfs4_ff_layoutstat *layoutstat)
			    struct nfs4_ff_layoutstat *layoutstat)
{
{
	static const ktime_t notime = {0};
	static const ktime_t notime = {0};
	ktime_t now = ktime_get();


	nfs4_ff_start_busy_timer(&layoutstat->busy_timer);
	nfs4_ff_start_busy_timer(&layoutstat->busy_timer);
	cmpxchg(&mirror->start_time, notime, ktime_get());
	cmpxchg(&mirror->start_time.tv64, notime.tv64, now.tv64);
	cmpxchg(&mirror->last_report_time.tv64, notime.tv64, now.tv64);
	if (ktime_to_ms(ktime_sub(now, mirror->last_report_time)) >=
			FF_LAYOUTSTATS_REPORT_INTERVAL) {
		mirror->last_report_time = now;
		return true;
	}

	return false;
}
}


static void
static void
@@ -496,10 +505,15 @@ static void
nfs4_ff_layout_stat_io_start_read(struct nfs4_ff_layout_mirror *mirror,
nfs4_ff_layout_stat_io_start_read(struct nfs4_ff_layout_mirror *mirror,
		__u64 requested)
		__u64 requested)
{
{
	bool report;

	spin_lock(&mirror->lock);
	spin_lock(&mirror->lock);
	nfs4_ff_layoutstat_start_io(mirror, &mirror->read_stat);
	report = nfs4_ff_layoutstat_start_io(mirror, &mirror->read_stat);
	nfs4_ff_layout_stat_io_update_requested(&mirror->read_stat, requested);
	nfs4_ff_layout_stat_io_update_requested(&mirror->read_stat, requested);
	spin_unlock(&mirror->lock);
	spin_unlock(&mirror->lock);

	if (report)
		pnfs_report_layoutstat(mirror->lseg->pls_layout->plh_inode);
}
}


static void
static void
@@ -519,10 +533,15 @@ static void
nfs4_ff_layout_stat_io_start_write(struct nfs4_ff_layout_mirror *mirror,
nfs4_ff_layout_stat_io_start_write(struct nfs4_ff_layout_mirror *mirror,
		__u64 requested)
		__u64 requested)
{
{
	bool report;

	spin_lock(&mirror->lock);
	spin_lock(&mirror->lock);
	nfs4_ff_layoutstat_start_io(mirror, &mirror->write_stat);
	report = nfs4_ff_layoutstat_start_io(mirror , &mirror->write_stat);
	nfs4_ff_layout_stat_io_update_requested(&mirror->write_stat, requested);
	nfs4_ff_layout_stat_io_update_requested(&mirror->write_stat, requested);
	spin_unlock(&mirror->lock);
	spin_unlock(&mirror->lock);

	if (report)
		pnfs_report_layoutstat(mirror->lseg->pls_layout->plh_inode);
}
}


static void
static void
+5 −1
Original line number Original line Diff line number Diff line
@@ -15,6 +15,9 @@
 * due to network error etc. */
 * due to network error etc. */
#define NFS4_FLEXFILE_LAYOUT_MAX_MIRROR_CNT 4096
#define NFS4_FLEXFILE_LAYOUT_MAX_MIRROR_CNT 4096


/* LAYOUTSTATS report interval in ms */
#define FF_LAYOUTSTATS_REPORT_INTERVAL (60000L)

struct nfs4_ff_ds_version {
struct nfs4_ff_ds_version {
	u32				version;
	u32				version;
	u32				minor_version;
	u32				minor_version;
@@ -62,6 +65,7 @@ struct nfs4_ff_layoutstat {
};
};


struct nfs4_ff_layout_mirror {
struct nfs4_ff_layout_mirror {
	struct pnfs_layout_segment	*lseg; /* back pointer */
	u32				ds_count;
	u32				ds_count;
	u32				efficiency;
	u32				efficiency;
	struct nfs4_ff_layout_ds	*mirror_ds;
	struct nfs4_ff_layout_ds	*mirror_ds;
@@ -75,7 +79,7 @@ struct nfs4_ff_layout_mirror {
	struct nfs4_ff_layoutstat	read_stat;
	struct nfs4_ff_layoutstat	read_stat;
	struct nfs4_ff_layoutstat	write_stat;
	struct nfs4_ff_layoutstat	write_stat;
	ktime_t				start_time;
	ktime_t				start_time;
	struct pnfs_layout_segment	*lseg; /* back pointer */
	ktime_t				last_report_time;
};
};


struct nfs4_ff_layout_segment {
struct nfs4_ff_layout_segment {