Discussion:
[PATCH 0/3] nilfs-utils: a few updates to utilize min_reclaimable_blocks
Ryusuke Konishi
2014-08-18 23:52:13 UTC
Permalink
This series remedies an inconvenience of nilfs-clean command related
to min_reclaimable_blocks parameter and enables set_suinfo ioctl use
by default in nilfs_cleanerd.conf.

The first patch changes nilfs-clean so that it doesn't override
min_reclaimable_blocks paramater when -m option is not explicitly
used.

The second patch just fixes a harmless issue in program of nilfs-clean.

And, the third patch changes the template file of nilfs_cleanerd.conf
so that nilfs_cleanerd tries to use set_suinfo ioctl by default if the
underlying kernel supports the feature.

Regards,
Ryuuke Konishi
--
man/nilfs-clean.8 | 1 -
sbin/cleanerd/nilfs_cleanerd.conf | 2 +-
sbin/nilfs-clean/nilfs-clean.c | 18 ++++++++++--------
3 files changed, 11 insertions(+), 10 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Ryusuke Konishi
2014-08-18 23:52:16 UTC
Permalink
Now set_suinfo ioctl is supported by nilfs2 kernel module in mainline.
This changes nilfs_cleanerd so that it tries to use the feature by
default. If it's not supported by the underlying kernel, the feature
will be disabled automatically.

Cc: Andreas Rohner <andreas.rohner-***@public.gmane.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke-***@public.gmane.org>
---
sbin/cleanerd/nilfs_cleanerd.conf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbin/cleanerd/nilfs_cleanerd.conf b/sbin/cleanerd/nilfs_cleanerd.conf
index 79d3fce..05cd9d4 100644
--- a/sbin/cleanerd/nilfs_cleanerd.conf
+++ b/sbin/cleanerd/nilfs_cleanerd.conf
@@ -69,7 +69,7 @@ mc_min_reclaimable_blocks 1%

# enable set_suinfo ioctl if supported
# (needed for min_reclaimable_blocks)
-#use_set_suinfo
+use_set_suinfo

# Use mmap when reading segments if supported.
use_mmap
--
1.7.9.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Ryusuke Konishi
2014-08-18 23:52:14 UTC
Permalink
The current implementation of nilfs-clean always overrides
min_reclaimable_blocks parameter and nilfs_cleanerd cannot use that
value defined in /etc/nilfs_cleanerd.conf for manual-mode gc
operation.

This resolves the issue by avoiding to override the
min_reclaimable_blocks parameter when -m option is not specified.

Cc: Andreas Rohner <andreas.rohner-***@public.gmane.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke-***@public.gmane.org>
---
man/nilfs-clean.8 | 1 -
sbin/nilfs-clean/nilfs-clean.c | 16 +++++++++-------
2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/man/nilfs-clean.8 b/man/nilfs-clean.8
index af39b6b..4bca51d 100644
--- a/man/nilfs-clean.8
+++ b/man/nilfs-clean.8
@@ -48,7 +48,6 @@ Specify the minimum number of reclaimable blocks in a segment before
it can be cleaned. If the argument is followed by a percent sign, it
represents the ratio of blocks in a segment. This argument will only have
an effect if the use_set_suinfo flag is set in the configuration file.
-The default value is one percent.
.TP
\fB\-p\fR, \fB\-\-protection-period=\fIinterval\fR
Set protection period for a cleaner run. The \fIinterval\fR parameter
diff --git a/sbin/nilfs-clean/nilfs-clean.c b/sbin/nilfs-clean/nilfs-clean.c
index 1f4c8f0..62130c4 100644
--- a/sbin/nilfs-clean/nilfs-clean.c
+++ b/sbin/nilfs-clean/nilfs-clean.c
@@ -130,9 +130,8 @@ static const char *conffile;
static unsigned long protection_period = ULONG_MAX;
static int nsegments_per_clean = 2;
static struct timespec cleaning_interval = { 0, 100000000 }; /* 100 msec */
-static unsigned long min_reclaimable_blocks = 1;
-static unsigned char min_reclaimable_blocks_unit =
- NILFS_CLEANER_ARG_UNIT_PERCENT;
+static unsigned long min_reclaimable_blocks = ULONG_MAX;
+static unsigned char min_reclaimable_blocks_unit = NILFS_CLEANER_ARG_UNIT_NONE;

static sigjmp_buf nilfs_clean_env;
static struct nilfs_cleaner *nilfs_cleaner;
@@ -173,18 +172,21 @@ static int nilfs_clean_do_run(struct nilfs_cleaner *cleaner)
args.nsegments_per_clean = nsegments_per_clean;
args.cleaning_interval = cleaning_interval.tv_sec;
args.cleaning_interval_nsec = cleaning_interval.tv_nsec;
- args.min_reclaimable_blocks = min_reclaimable_blocks;
- args.min_reclaimable_blocks_unit = min_reclaimable_blocks_unit;
args.valid = (NILFS_CLEANER_ARG_NPASSES |
NILFS_CLEANER_ARG_CLEANING_INTERVAL |
- NILFS_CLEANER_ARG_NSEGMENTS_PER_CLEAN |
- NILFS_CLEANER_ARG_MIN_RECLAIMABLE_BLOCKS);
+ NILFS_CLEANER_ARG_NSEGMENTS_PER_CLEAN);

if (protection_period != ULONG_MAX) {
args.protection_period = protection_period;
args.valid |= NILFS_CLEANER_ARG_PROTECTION_PERIOD;
}

+ if (min_reclaimable_blocks != ULONG_MAX) {
+ args.min_reclaimable_blocks = min_reclaimable_blocks;
+ args.min_reclaimable_blocks_unit = min_reclaimable_blocks_unit;
+ args.valid |= NILFS_CLEANER_ARG_MIN_RECLAIMABLE_BLOCKS;
+ }
+
if (nilfs_cleaner_run(cleaner, &args, NULL) < 0) {
myprintf(_("Error: cannot run cleaner: %s\n"),
strerror(errno));
--
1.7.9.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Ryusuke Konishi
2014-08-18 23:52:15 UTC
Permalink
nilfs_clean_parse_min_reclaimable() function changes value of
min_reclaimable_blocks_unit even if a given percentage value is
invalid. Although it doesn't cause any actual problems since its only
caller, nilfs_clean_parse_options(), will immediately abort the
program when nilfs_clean_parse_min_reclaimable() returned an error
status code (-1), it is not sane for
nilfs_clean_parse_min_reclaimable() function itself.

Cc: Andreas Rohner <andreas.rohner-***@public.gmane.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke-***@public.gmane.org>
---
sbin/nilfs-clean/nilfs-clean.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbin/nilfs-clean/nilfs-clean.c b/sbin/nilfs-clean/nilfs-clean.c
index 62130c4..ab2180a 100644
--- a/sbin/nilfs-clean/nilfs-clean.c
+++ b/sbin/nilfs-clean/nilfs-clean.c
@@ -407,12 +407,12 @@ static int nilfs_clean_parse_min_reclaimable(const char *arg)
}

if (endptr[0] == '%') {
- min_reclaimable_blocks_unit = NILFS_CLEANER_ARG_UNIT_PERCENT;
if (blocks > 100) {
myprintf(_("Error: percent value can't be > 100: %s\n"),
arg);
return -1;
}
+ min_reclaimable_blocks_unit = NILFS_CLEANER_ARG_UNIT_PERCENT;
} else {
min_reclaimable_blocks_unit = NILFS_CLEANER_ARG_UNIT_NONE;
}
--
1.7.9.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Loading...