aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c27
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.h6
2 files changed, 28 insertions, 5 deletions
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 6bcb6d6c9dc3..d3b3b6236711 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -452,14 +452,23 @@ nfs4_ff_layout_calc_completion_time(struct rpc_task *task)
452 return ktime_sub(ktime_get(), task->tk_start); 452 return ktime_sub(ktime_get(), task->tk_start);
453} 453}
454 454
455static void 455static bool
456nfs4_ff_layoutstat_start_io(struct nfs4_ff_layout_mirror *mirror, 456nfs4_ff_layoutstat_start_io(struct nfs4_ff_layout_mirror *mirror,
457 struct nfs4_ff_layoutstat *layoutstat) 457 struct nfs4_ff_layoutstat *layoutstat)
458{ 458{
459 static const ktime_t notime = {0}; 459 static const ktime_t notime = {0};
460 ktime_t now = ktime_get();
460 461
461 nfs4_ff_start_busy_timer(&layoutstat->busy_timer); 462 nfs4_ff_start_busy_timer(&layoutstat->busy_timer);
462 cmpxchg(&mirror->start_time, notime, ktime_get()); 463 cmpxchg(&mirror->start_time.tv64, notime.tv64, now.tv64);
464 cmpxchg(&mirror->last_report_time.tv64, notime.tv64, now.tv64);
465 if (ktime_to_ms(ktime_sub(now, mirror->last_report_time)) >=
466 FF_LAYOUTSTATS_REPORT_INTERVAL) {
467 mirror->last_report_time = now;
468 return true;
469 }
470
471 return false;
463} 472}
464 473
465static void 474static void
@@ -496,10 +505,15 @@ static void
496nfs4_ff_layout_stat_io_start_read(struct nfs4_ff_layout_mirror *mirror, 505nfs4_ff_layout_stat_io_start_read(struct nfs4_ff_layout_mirror *mirror,
497 __u64 requested) 506 __u64 requested)
498{ 507{
508 bool report;
509
499 spin_lock(&mirror->lock); 510 spin_lock(&mirror->lock);
500 nfs4_ff_layoutstat_start_io(mirror, &mirror->read_stat); 511 report = nfs4_ff_layoutstat_start_io(mirror, &mirror->read_stat);
501 nfs4_ff_layout_stat_io_update_requested(&mirror->read_stat, requested); 512 nfs4_ff_layout_stat_io_update_requested(&mirror->read_stat, requested);
502 spin_unlock(&mirror->lock); 513 spin_unlock(&mirror->lock);
514
515 if (report)
516 pnfs_report_layoutstat(mirror->lseg->pls_layout->plh_inode);
503} 517}
504 518
505static void 519static void
@@ -519,10 +533,15 @@ static void
519nfs4_ff_layout_stat_io_start_write(struct nfs4_ff_layout_mirror *mirror, 533nfs4_ff_layout_stat_io_start_write(struct nfs4_ff_layout_mirror *mirror,
520 __u64 requested) 534 __u64 requested)
521{ 535{
536 bool report;
537
522 spin_lock(&mirror->lock); 538 spin_lock(&mirror->lock);
523 nfs4_ff_layoutstat_start_io(mirror, &mirror->write_stat); 539 report = nfs4_ff_layoutstat_start_io(mirror , &mirror->write_stat);
524 nfs4_ff_layout_stat_io_update_requested(&mirror->write_stat, requested); 540 nfs4_ff_layout_stat_io_update_requested(&mirror->write_stat, requested);
525 spin_unlock(&mirror->lock); 541 spin_unlock(&mirror->lock);
542
543 if (report)
544 pnfs_report_layoutstat(mirror->lseg->pls_layout->plh_inode);
526} 545}
527 546
528static void 547static void
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h
index 7e248874f46d..6fcd8d5e8e3d 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.h
+++ b/fs/nfs/flexfilelayout/flexfilelayout.h
@@ -15,6 +15,9 @@
15 * due to network error etc. */ 15 * due to network error etc. */
16#define NFS4_FLEXFILE_LAYOUT_MAX_MIRROR_CNT 4096 16#define NFS4_FLEXFILE_LAYOUT_MAX_MIRROR_CNT 4096
17 17
18/* LAYOUTSTATS report interval in ms */
19#define FF_LAYOUTSTATS_REPORT_INTERVAL (60000L)
20
18struct nfs4_ff_ds_version { 21struct nfs4_ff_ds_version {
19 u32 version; 22 u32 version;
20 u32 minor_version; 23 u32 minor_version;
@@ -62,6 +65,7 @@ struct nfs4_ff_layoutstat {
62}; 65};
63 66
64struct nfs4_ff_layout_mirror { 67struct nfs4_ff_layout_mirror {
68 struct pnfs_layout_segment *lseg; /* back pointer */
65 u32 ds_count; 69 u32 ds_count;
66 u32 efficiency; 70 u32 efficiency;
67 struct nfs4_ff_layout_ds *mirror_ds; 71 struct nfs4_ff_layout_ds *mirror_ds;
@@ -75,7 +79,7 @@ struct nfs4_ff_layout_mirror {
75 struct nfs4_ff_layoutstat read_stat; 79 struct nfs4_ff_layoutstat read_stat;
76 struct nfs4_ff_layoutstat write_stat; 80 struct nfs4_ff_layoutstat write_stat;
77 ktime_t start_time; 81 ktime_t start_time;
78 struct pnfs_layout_segment *lseg; /* back pointer */ 82 ktime_t last_report_time;
79}; 83};
80 84
81struct nfs4_ff_layout_segment { 85struct nfs4_ff_layout_segment {