053-0002-ubifs-Use-dirty_writeback_interval-value-for-wbuf-ti.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From 1b7fc2c0069f3864a3dda15430b7aded31c0bfcc Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Tue, 20 Sep 2016 10:36:15 +0200
  4. Subject: [PATCH] ubifs: Use dirty_writeback_interval value for wbuf timer
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Right now wbuf timer has hardcoded timeouts and there is no place for
  9. manual adjustments. Some projects / cases many need that though. Few
  10. file systems allow doing that by respecting dirty_writeback_interval
  11. that can be set using sysctl (dirty_writeback_centisecs).
  12. Lowering dirty_writeback_interval could be some way of dealing with user
  13. space apps lacking proper fsyncs. This is definitely *not* a perfect
  14. solution but we don't have ideal (user space) world. There were already
  15. advanced discussions on this matter, mostly when ext4 was introduced and
  16. it wasn't behaving as ext3. Anyway, the final decision was to add some
  17. hacks to the ext4, as trying to fix whole user space or adding new API
  18. was pointless.
  19. We can't (and shouldn't?) just follow ext4. We can't e.g. sync on close
  20. as this would cause too many commits and flash wearing. On the other
  21. hand we still should allow some trade-off between -o sync and default
  22. wbuf timeout. Respecting dirty_writeback_interval should allow some sane
  23. cutomizations if used warily.
  24. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  25. Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
  26. Signed-off-by: Richard Weinberger <richard@nod.at>
  27. ---
  28. fs/ubifs/io.c | 8 ++++----
  29. fs/ubifs/ubifs.h | 4 ----
  30. 2 files changed, 4 insertions(+), 8 deletions(-)
  31. --- a/fs/ubifs/io.c
  32. +++ b/fs/ubifs/io.c
  33. @@ -452,11 +452,11 @@ static enum hrtimer_restart wbuf_timer_c
  34. */
  35. static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf)
  36. {
  37. - ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0);
  38. - unsigned long long delta;
  39. + ktime_t softlimit = ms_to_ktime(dirty_writeback_interval * 10);
  40. + unsigned long long delta = dirty_writeback_interval;
  41. - delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT;
  42. - delta *= 1000000000ULL;
  43. + /* centi to milli, milli to nano, then 10% */
  44. + delta *= 10ULL * NSEC_PER_MSEC / 10ULL;
  45. ubifs_assert(!hrtimer_active(&wbuf->timer));
  46. ubifs_assert(delta <= ULONG_MAX);
  47. --- a/fs/ubifs/ubifs.h
  48. +++ b/fs/ubifs/ubifs.h
  49. @@ -106,10 +106,6 @@
  50. */
  51. #define BGT_NAME_PATTERN "ubifs_bgt%d_%d"
  52. -/* Write-buffer synchronization timeout interval in seconds */
  53. -#define WBUF_TIMEOUT_SOFTLIMIT 3
  54. -#define WBUF_TIMEOUT_HARDLIMIT 5
  55. -
  56. /* Maximum possible inode number (only 32-bit inodes are supported now) */
  57. #define MAX_INUM 0xFFFFFFFF