nilfs-utils: shortcut for certain GC operations
Subsystems (2)
v6 cover nilfs-utils: shortcut for certain GC operations
Hi,
This patch set adds an optimized version of nilfs_xreclaim_segments, which has an additional parameter min_reclaimable_blks. This parameter specifies the minimum number of reclaimable blocks in a segment, before it can be cleaned. If a segment is below this threshold, it is considered to be not worth cleaning, because all the live blocks would need to be moved to a new segment, which is expensive, and the number of reclaimable blocks is too low. But it is still necessary to update the segment usage information to turn the old segment into a new one.
This is basically a shortcut to cleaning the segment. It is still necessary to read the segment summary information, but the writing of the live blocks can be skipped if it's not worth it.
Additionally new options are introduced for the configuration file and nilfs-clean to allow the user to specify the threshold.
This is potentially useful for all gc policies, but it is especially beneficial for the timestamp policy. Lets assume for example a NILFS2 volume with 20% static files and lets assume these static files are in the oldest segments. The current timestamp policy will select the oldest segments and, since the data is static, move them mostly unchanged to new segments. After a while they will become the oldest segments again. Then timestamp will move them again. These moving operations are expensive and unnecessary.
Regards,
Andreas Rohner
---v5->v6 (based on review by Ryusuke Konishi)
* Add support for percent in nilfs-clean -m argument
* Change location of nilfs_opt_test_set_suinfo check
* Change interpretation of stat.cleaned_segs and stat.deferred_segs to be not exclusive
v4->v5 (based on review by Ryusuke Konishi)
* Add missing comments and documentation
* Fix nilfs_set_suinfo return value
* Fix coding style issues
* Return error if invalid min_reclaimable_blocks is sent from nilfs-clean command
* Use nilfs_vector instead of malloc in nilfs_xreclaim_segment
* Rename nilfs_reclaim_params flag to NILFS_RECLAIM_PARAM_MIN_RECLAIMABLE_BLKS
* Changed the interpretation of deferred_segs in nilfs_reclaim_stat
v3->v4 (based on review by Ryusuke Konishi)
* nilfs-utils: Rebase on refactored nilfs_reclaim_segments (by Ryusuke Konishi)
* nilfs-utils: Add no_timeout if cleaning was deferred
v2->v3 (based on review by Ryusuke Konishi)
* Alignment in nilfs_suinfo_update
* Add missing comments
* nilfs2: Extra validity checks in nilfs_sufile_set_suinfo
* nilfs2: Update sh_ncleansegs, sh_ndirtysegs if flags change
* nilfs2: Fix bugs in nilfs_sufile_set_suinfo
* nilfs2: Use vmalloc instead of ioctl_wrap_copy
* nilfs-utils: Separate nilfs_relaim_segments_with_threshold
* nilfs-utils: Allow different units for min_reclaimable_blocks
* nilfs-utils: Introduce flag to disable the optimization
* nilfs-utils: Disable optimization if kernel retruns ENOTTY
* nilfs-utils: Remove EGCTRYAGAIN error return code
* nilfs-utils: Rename option to min_reclaimable_blocks
v1->v2 (based on review by Ryusuke Konishi)
* Implementation of NILFS_IOCTL_SET_SUINFO
* Added mc_min_free_blocks_threshold config option
(if clean segments < min_clean_segments)
* Added new command line param for nilfs-clean
* Update man- and config-file
--
Andreas Rohner (6):
nilfs-utils: cldconfig add an option to set min. reclaimable blocks
nilfs-utils: add NILFS_OPT_SET_SUINFO
nilfs-utils: nilfs-clean add cmdline param min-reclaimable-blocks
nilfs-utils: add suport for NILFS_IOCTL_SET_SUINFO ioctl
nilfs-utils: add optimized version of nilfs_xreclaim_segments
nilfs-utils: add a no_timeout flag to enable faster loop
include/nilfs.h | 9 +- include/nilfs2_fs.h | 44 ++++++++++ include/nilfs_cleaner.h | 43 +++++++--- include/nilfs_gc.h | 11 +-- lib/gc.c | 74 +++++++++++++++-- lib/nilfs.c | 59 +++++++++++++ man/nilfs-clean.8 | 7 ++ man/nilfs_cleanerd.conf.5 | 22 +++++ sbin/cleanerd/cldconfig.c | 169 ++++++++++++++++++++++++++++---------- sbin/cleanerd/cldconfig.h | 12 +++ sbin/cleanerd/cleanerd.c | 100 ++++++++++++++++++++-- sbin/cleanerd/nilfs_cleanerd.conf | 20 +++++ sbin/nilfs-clean/nilfs-clean.c | 58 +++++++++++-- 13 files changed, 549 insertions(+), 79 deletions(-)
Signature · 6 lines
1.8.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v6 1/6 nilfs-utils: cldconfig add an option to set min. reclaimable blocks
With this option the user can specify the minimum number of reclaimable blocks of a segment, before it can be cleaned. This is a threshold for the GC to prevent needless moving of data. If there are less reclaimable blocks in a segment than the specified number, the GC will abort and try again with a different segment.
If there are less clean segments than min_clean_segments, mc_min_reclaimable_blocks is used instead of min_reclaimable_blocks. This allows for more flexibility in configuring the GC.
The number of blocks can be specified in percent of a segment or in bytes.
If the use_set_suinfo switch is not set, the optimization is completely disabled.
--- man/nilfs_cleanerd.conf.5 | 22 +++++ sbin/cleanerd/cldconfig.c | 169 ++++++++++++++++++++++++++++---------- sbin/cleanerd/cldconfig.h | 12 +++ sbin/cleanerd/cleanerd.c | 10 +++ sbin/cleanerd/nilfs_cleanerd.conf | 20 +++++ 5 files changed, 191 insertions(+), 42 deletions(-)
man/nilfs_cleanerd.conf.5 +22 -0
@@ -79,6 +79,28 @@ Specify whether to use \fBmmap\fP(2) for reading segments. At present, this option is enabled if supported regardless of this directive. .TP +.B use_set_suinfo +Specify whether to use the set_suinfo ioctl if it is supported. This is +necessary for the \fBmin_reclaimable_blocks\fP feature. By disabling this +switch \fBmin_reclaimable_blocks\fP is also disabled. +.TP +.B min_reclaimable_blocks +Specify the minimum number of reclaimable blocks in a segment before +it can be cleaned. +.TP +.B mc_min_reclaimable_blocks +Specify the minimum number of reclaimable blocks in a segment before +it can be cleaned. if clean segments < min_clean_segments. +.PP +\fBmin_reclaimable_blocks\fP and \fBmc_min_reclaimable_blocks\fP may +be followed by a percent sign or the following multiplicative suffixes: +kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G +1024*1024*1024, and so on for T, P, E. If the argument is followed by +a percent sign, it represents the ratio of blocks in a segment. +.PP +The default values of \fBmin_reclaimable_blocks\fP and +\fBmc_min_reclaimable_blocks\fP are 5 percent and 1 percent respectively. +.TP .B log_priority Gives the verbosity level that is used when logging messages from \fBnilfs_cleanerd\fP(8). The possible values are: \fBemerg\fP,
sbin/cleanerd/cldconfig.c +127 -42
206 lines not on this page · raw message
sbin/cleanerd/cldconfig.h +12 -0
@@ -87,7 +87,11 @@ enum nilfs_size_unit {* if clean segments < min_clean_segments * @cf_retry_interval: retry interval * @cf_use_mmap: flag that indicate using mmap +* @cf_use_set_suinfo: flag that indicates the use of the set_suinfo ioctl * @cf_log_priority: log priority level +* @cf_min_reclaimable_blocks: minimum reclaimable blocks for cleaning +* @cf_mc_min_reclaimable_blocks: minimum reclaimable blocks for cleaning +* if clean segments < min_clean_segments */ struct nilfs_cldconfig {struct nilfs_selection_policy cf_selection_policy;
@@ -101,7 +105,10 @@ struct nilfs_cldconfig {struct timeval cf_mc_cleaning_interval;struct timeval cf_retry_interval;int cf_use_mmap; +int cf_use_set_suinfo;int cf_log_priority; +unsigned long cf_min_reclaimable_blocks; +unsigned long cf_mc_min_reclaimable_blocks; };#define NILFS_CLDCONFIG_SELECTION_POLICY_IMPORTANCE \
@@ -119,7 +126,12 @@ struct nilfs_cldconfig {#define NILFS_CLDCONFIG_MC_CLEANING_INTERVAL 1#define NILFS_CLDCONFIG_RETRY_INTERVAL 60#define NILFS_CLDCONFIG_USE_MMAP 1 +#define NILFS_CLDCONFIG_USE_SET_SUINFO 0#define NILFS_CLDCONFIG_LOG_PRIORITY LOG_INFO +#define NILFS_CLDCONFIG_MIN_RECLAIMABLE_BLOCKS 5 +#define NILFS_CLDCONFIG_MIN_RECLAIMABLE_BLOCKS_UNIT NILFS_SIZE_UNIT_PERCENT +#define NILFS_CLDCONFIG_MC_MIN_RECLAIMABLE_BLOCKS 1 +#define NILFS_CLDCONFIG_MC_MIN_RECLAIMABLE_BLOCKS_UNIT NILFS_SIZE_UNIT_PERCENT#define NILFS_CLDCONFIG_NSEGMENTS_PER_CLEAN_MAX 32
sbin/cleanerd/cleanerd.c +10 -0
@@ -145,6 +145,7 @@ const static struct option long_option[] = {* @cleaning_interval: cleaning interval * @target: target time for sleeping * @timeout: timeout value for sleeping +* @min_reclaimable_blocks: min. number of reclaimable blocks * @prev_nongc_ctime: previous nongc ctime * @recvq: receive queue * @recvq_name: receive queue name
@@ -172,6 +173,7 @@ struct nilfs_cleanerd {struct timeval cleaning_interval;struct timeval target;struct timeval timeout; +unsigned long min_reclaimable_blocks;__u64 prev_nongc_ctime;mqd_t recvq;char *recvq_name;
@@ -273,6 +275,8 @@ static int nilfs_cleanerd_reconfig(struct nilfs_cleanerd *cleanerd, }else { cleanerd->ncleansegs = config->cf_nsegments_per_clean; cleanerd->cleaning_interval = config->cf_cleaning_interval; + cleanerd->min_reclaimable_blocks = + config->cf_min_reclaimable_blocks;syslog (LOG_INFO ,"configuration file reloaded" ); }return ret;
@@ -1238,10 +1242,14 @@ static int nilfs_cleanerd_handle_clean_check(struct nilfs_cleanerd *cleanerd,/* disk space is close to limit -- accelerate cleaning */ cleanerd->ncleansegs = config->cf_mc_nsegments_per_clean; cleanerd->cleaning_interval = config->cf_mc_cleaning_interval; + cleanerd->min_reclaimable_blocks = + config->cf_mc_min_reclaimable_blocks; }else {/* continue to run */ cleanerd->ncleansegs = config->cf_nsegments_per_clean; cleanerd->cleaning_interval = config->cf_cleaning_interval; + cleanerd->min_reclaimable_blocks = + config->cf_min_reclaimable_blocks; }return 0 ;/* do gc */
@@ -1442,6 +1450,8 @@ static int nilfs_cleanerd_clean_loop(struct nilfs_cleanerd *cleanerd) cleanerd->ncleansegs = cleanerd->config.cf_nsegments_per_clean; cleanerd->cleaning_interval = cleanerd->config.cf_cleaning_interval; + cleanerd->min_reclaimable_blocks = + cleanerd->config.cf_min_reclaimable_blocks;if (nilfs_cleanerd_automatic_suspend (cleanerd))
sbin/cleanerd/nilfs_cleanerd.conf +20 -0
@@ -51,6 +51,26 @@ mc_cleaning_interval 1 # Retry interval in seconds. retry_interval 60 +# Specify the minimum number of reclaimable blocks in a segment +# before it can be cleaned. +min_reclaimable_blocks 5% + +# Specify the minimum number of reclaimable blocks in a segment +# before it can be cleaned. +# if clean segments < min_clean_segments +mc_min_reclaimable_blocks 1% + +# The argument of min_reclaimable_blocks and mc_min_reclaimable_blocks +# can be followed by a percent sign (%) or one of the following +# multiplicative suffixes similar to min_clean_segments. +# +# If the argument is followed by "%", it represents a ratio for the +# number of blocks per segment. + +# enable set_suinfo ioctl if supported +# (needed for min_reclaimable_blocks) +#use_set_suinfo + # Use mmap when reading segments if supported. use_mmap
Signature · 6 lines
1.8.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 2/6 nilfs-utils: add NILFS_OPT_SET_SUINFO
In reply to a message not in the archiveThis option for the nilfs object corresponds to the use_set_suinfo flag in the configuration file. This patch adds the flag itself plus some convenience functions.
The option is set after the configuration file was read in.
--- include/nilfs.h | 7 ++++++- lib/nilfs.c | 28 ++++++++++++++++++++++++++++ sbin/cleanerd/cleanerd.c | 6 ++++++ 3 files changed, 40 insertions(+), 1 deletion(-)
include/nilfs.h +6 -1
@@ -128,7 +128,8 @@ struct nilfs {#define NILFS_OPEN_RDWR 0x0008/* Open NILFS API in read/write mode */ #define NILFS_OPEN_GCLK 0x1000/* Open GC lock primitive */ -#define NILFS_OPT_MMAP 0x01 +#define NILFS_OPT_MMAP 0x01 +#define NILFS_OPT_SET_SUINFO 0x02struct nilfs *nilfs_open (const char *,const char *,int );
@@ -140,6 +141,10 @@ void nilfs_opt_clear_mmap(struct nilfs *);int nilfs_opt_set_mmap (struct nilfs *);int nilfs_opt_test_mmap (struct nilfs *); +void nilfs_opt_clear_set_suinfo (struct nilfs *); +int nilfs_opt_set_set_suinfo (struct nilfs *); +int nilfs_opt_test_set_suinfo (struct nilfs *); +nilfs_cno_t nilfs_get_oldest_cno (struct nilfs *);struct nilfs_super_block *nilfs_get_sb (struct nilfs *);
lib/nilfs.c +28 -0
@@ -288,6 +288,34 @@ int nilfs_opt_test_mmap(struct nilfs *nilfs)return !!(nilfs->n_opts &NILFS_OPT_MMAP ); } +/** +* nilfs_opt_set_set_suinfo - set set_suinfo option +* @nilfs: nilfs object +*/ +int nilfs_opt_set_set_suinfo (struct nilfs *nilfs) +{ + nilfs->n_opts |=NILFS_OPT_SET_SUINFO ; +return 0 ; +} + +/** +* nilfs_opt_clear_set_suinfo - clear set_suinfo option +* @nilfs: nilfs object +*/ +void nilfs_opt_clear_set_suinfo (struct nilfs *nilfs) +{ + nilfs->n_opts &= ~NILFS_OPT_SET_SUINFO ; +} + +/** +* nilfs_opt_test_set_suinfo - test whether set_suinfo option is set or not +* @nilfs: nilfs object +*/ +int nilfs_opt_test_set_suinfo (struct nilfs *nilfs) +{ +return !!(nilfs->n_opts &NILFS_OPT_SET_SUINFO ); +} +static int nilfs_open_sem (struct nilfs *nilfs) {char semnambuf[NAME_MAX -4 ];
sbin/cleanerd/cleanerd.c +6 -0
@@ -248,6 +248,12 @@ static int nilfs_cleanerd_config(struct nilfs_cleanerd *cleanerd, else nilfs_opt_clear_mmap(cleanerd->nilfs);#endif /* HAVE_MMAP */ + +if (cleanerd->config.cf_use_set_suinfo) +nilfs_opt_set_set_suinfo (cleanerd->nilfs); +else +nilfs_opt_clear_set_suinfo (cleanerd->nilfs); +nilfs_cleanerd_set_log_priority (cleanerd);if (protection_period !=ULONG_MAX ) {
Signature · 6 lines
1.8.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 3/6 nilfs-utils: nilfs-clean add cmdline param min-reclaimable-blocks
In reply to a message not in the archiveThis patch adds a command line parameter for nilfs-clean to allow the manual override of the min_reclaimable_blocks option.
--- include/nilfs_cleaner.h | 43 +++++++++++++++++++++++-------- man/nilfs-clean.8 | 7 +++++ sbin/cleanerd/cleanerd.c | 37 +++++++++++++++++++++++++++ sbin/nilfs-clean/nilfs-clean.c | 58 +++++++++++++++++++++++++++++++++++++----- 4 files changed, 129 insertions(+), 16 deletions(-)
include/nilfs_cleaner.h +33 -10
@@ -39,24 +39,47 @@ struct nilfs_cleaner_args {uint16_t npasses;/* number of passes */ uint16_t usage_rate_threshold;uint16_t nsegments_per_clean; -uint16_t pad1; +uint8_t pad; +uint8_t min_reclaimable_blocks_unit;uint16_t cleaning_interval;uint32_t cleaning_interval_nsec;uint64_t protection_period;/* protection period in seconds */ uint64_t start_segnum;/* start segment number */ uint64_t nsegs;/* number of segments */ uint32_t runtime;/* runtime in seconds */ -uint32_t pad2; +uint32_t min_reclaimable_blocks; }; + +enum nilfs_cleaner_args_unit { +NILFS_CLEANER_ARG_UNIT_NONE =0 , +NILFS_CLEANER_ARG_UNIT_PERCENT , +NILFS_CLEANER_ARG_UNIT_KB ,/* kilo-byte (kB) */ +NILFS_CLEANER_ARG_UNIT_KIB ,/* kibi-byte (KiB) */ +NILFS_CLEANER_ARG_UNIT_MB ,/* mega-byte (MB) */ +NILFS_CLEANER_ARG_UNIT_MIB ,/* mebi-byte (MiB) */ +NILFS_CLEANER_ARG_UNIT_GB ,/* giga-byte (GB) */ +NILFS_CLEANER_ARG_UNIT_GIB ,/* gibi-byte (GiB) */ +NILFS_CLEANER_ARG_UNIT_TB ,/* tera-byte (TB) */ +NILFS_CLEANER_ARG_UNIT_TIB ,/* tebi-byte (TiB) */ +NILFS_CLEANER_ARG_UNIT_PB ,/* peta-byte (PB) */ +NILFS_CLEANER_ARG_UNIT_PIB ,/* pebi-byte (PiB) */ +NILFS_CLEANER_ARG_UNIT_EB ,/* exa-byte (EB) */ +NILFS_CLEANER_ARG_UNIT_EIB ,/* exbi-byte (EiB) */ + +NILFS_CLEANER_ARG_MIN_BINARY_SUFFIX =NILFS_CLEANER_ARG_UNIT_KB , +NILFS_CLEANER_ARG_MAX_BINARY_SUFFIX =NILFS_CLEANER_ARG_UNIT_EIB , +}; +/* valid flags */ -#define NILFS_CLEANER_ARG_PROTECTION_PERIOD (1 << 0) -#define NILFS_CLEANER_ARG_NSEGMENTS_PER_CLEAN (1 << 1) -#define NILFS_CLEANER_ARG_CLEANING_INTERVAL (1 << 2) -#define NILFS_CLEANER_ARG_USAGE_RATE_THRESHOLD (1 << 3)/* reserved */ -#define NILFS_CLEANER_ARG_START_SEGNUM (1 << 4)/* reserved */ -#define NILFS_CLEANER_ARG_NSEGS (1 << 5)/* reserved */ -#define NILFS_CLEANER_ARG_NPASSES (1 << 6)/* reserved */ -#define NILFS_CLEANER_ARG_RUNTIME (1 << 7)/* reserved */ +#define NILFS_CLEANER_ARG_PROTECTION_PERIOD (1 << 0) +#define NILFS_CLEANER_ARG_NSEGMENTS_PER_CLEAN (1 << 1) +#define NILFS_CLEANER_ARG_CLEANING_INTERVAL (1 << 2) +#define NILFS_CLEANER_ARG_USAGE_RATE_THRESHOLD (1 << 3)/* reserved */ +#define NILFS_CLEANER_ARG_START_SEGNUM (1 << 4)/* reserved */ +#define NILFS_CLEANER_ARG_NSEGS (1 << 5)/* reserved */ +#define NILFS_CLEANER_ARG_NPASSES (1 << 6)/* reserved */ +#define NILFS_CLEANER_ARG_RUNTIME (1 << 7)/* reserved */ +#define NILFS_CLEANER_ARG_MIN_RECLAIMABLE_BLOCKS (1 << 8)enum {NILFS_CLEANER_STATUS_IDLE ,
man/nilfs-clean.8 +7 -0
@@ -43,6 +43,13 @@ Display cleaner status. \fB\-h\fR, \fB\-\-help\fR Display help message and exit. .TP +\fB\-m\fR, \fB\-\-min\-reclaimable\-blocks=\fICOUNT[%]\fR +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 is an integer value and specifies the minimum time that deleted or
sbin/cleanerd/cleanerd.c +37 -0
@@ -159,6 +159,7 @@ const static struct option long_option[] = {* @mm_ncleansegs: number of segmetns cleaned per cycle (manual mode) * @mm_protection_period: protection period (manual mode) * @mm_cleaning_interval: cleaning interval (manual mode) +* @mm_min_reclaimable_blocks: min. number of reclaimable blocks (manual mode) */ struct nilfs_cleanerd {struct nilfs *nilfs;
@@ -186,6 +187,7 @@ struct nilfs_cleanerd {long mm_ncleansegs;struct timeval mm_protection_period;struct timeval mm_cleaning_interval; +unsigned long mm_min_reclaimable_blocks; };/**
@@ -469,6 +471,14 @@ nilfs_cleanerd_protection_period(struct nilfs_cleanerd *cleanerd) &cleanerd->config.cf_protection_period; } +static unsigned long +nilfs_cleanerd_min_reclaimable_blocks (struct nilfs_cleanerd *cleanerd) +{ +return cleanerd->running ==2 ? + cleanerd->mm_min_reclaimable_blocks : + cleanerd->min_reclaimable_blocks; +} +static void nilfs_cleanerd_reduce_ncleansegs_for_retry (struct nilfs_cleanerd *cleanerd) {
@@ -1011,6 +1021,33 @@ static int nilfs_cleanerd_cmd_run(struct nilfs_cleanerd *cleanerd, cleanerd->mm_cleaning_interval = cleanerd->cleaning_interval; } +/* minimal reclaimable blocks */ +if (req2->args.valid &NILFS_CLEANER_ARG_MIN_RECLAIMABLE_BLOCKS ) { +switch (req2->args.min_reclaimable_blocks_unit) { +case NILFS_CLEANER_ARG_UNIT_NONE : +if (req2->args.min_reclaimable_blocks > +nilfs_get_blocks_per_segment (cleanerd->nilfs)) + goto error_inval; + + cleanerd->mm_min_reclaimable_blocks = + req2->args.min_reclaimable_blocks; +break ; +case NILFS_CLEANER_ARG_UNIT_PERCENT : +if (req2->args.min_reclaimable_blocks >100 ) + goto error_inval; + + cleanerd->mm_min_reclaimable_blocks = + (req2->args.min_reclaimable_blocks * +nilfs_get_blocks_per_segment (cleanerd->nilfs) + +99 ) /100 ; +break ; +default : + goto error_inval; + } + }else { + cleanerd->mm_min_reclaimable_blocks = + cleanerd->min_reclaimable_blocks; + }/* number of passes */ if (req2->args.valid &NILFS_CLEANER_ARG_NPASSES ) {if (!req2->args.npasses)
sbin/nilfs-clean/nilfs-clean.c +52 -6
110 lines not on this page · raw message
Signature · 6 lines
1.8.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 4/6 nilfs-utils: add suport for NILFS_IOCTL_SET_SUINFO ioctl
In reply to a message not in the archiveThis patch adds library support for the NILFS_IOCTL_SET_SUINFO ioctl. A new function nilfs_set_suinfo and the structure nilfs_suinfo_update, which contains the update information, are added.
With this function the segment usage information can be updated from userspace, which can be used as a shortcut for certain GC operations.
--- include/nilfs.h | 2 ++ include/nilfs2_fs.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ lib/nilfs.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+)
include/nilfs.h +2 -0
@@ -304,6 +304,8 @@ int nilfs_delete_checkpoint(struct nilfs *, nilfs_cno_t);int nilfs_get_cpstat (const struct nilfs *,struct nilfs_cpstat *);ssize_t nilfs_get_suinfo (const struct nilfs *,__u64 ,struct nilfs_suinfo *,size_t ); +int nilfs_set_suinfo (const struct nilfs *,struct nilfs_suinfo_update *, +size_t );int nilfs_get_sustat (const struct nilfs *,struct nilfs_sustat *);ssize_t nilfs_get_vinfo (const struct nilfs *,struct nilfs_vinfo *,size_t );ssize_t nilfs_get_bdescs (const struct nilfs *,struct nilfs_bdesc *,size_t );
include/nilfs2_fs.h +44 -0
55 lines not on this page · raw message
lib/nilfs.c +31 -0
@@ -596,6 +596,37 @@ ssize_t nilfs_get_suinfo(const struct nilfs *nilfs, __u64 segnum, }/** +* nilfs_set_suinfo - sets segment usage info +* @nilfs: nilfs object +* @sup: an array of nilfs_suinfo_update structs +* @nsup: number of elements in sup +* +* Description: Takes an array of nilfs_suinfo_update structs and updates +* segment usage info accordingly. Only the fields indicated by sup_flags +* are updated. +* +* Return Value: On success, 0 is returned. On error, -1 is returned. +*/ +int nilfs_set_suinfo (const struct nilfs *nilfs, +struct nilfs_suinfo_update *sup,size_t nsup) +{ +struct nilfs_argv argv; + +if (nilfs->n_iocfd <0 ) { + errno =EBADF ; +return -1 ; + } + + argv.v_base = (unsigned long )sup; + argv.v_nmembs = nsup; + argv.v_size =sizeof (struct nilfs_suinfo_update ); + argv.v_index =0 ; + argv.v_flags =0 ; + +return ioctl (nilfs->n_iocfd,NILFS_IOCTL_SET_SUINFO , &argv); +} + +/** * nilfs_get_sustat - get segment usage statistics * @nilfs: nilfs object * @sustat: buffer of a nilfs_sustat struct to store statistics in
Signature · 6 lines
1.8.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 5/6 nilfs-utils: add optimized version of nilfs_xreclaim_segments
In reply to a message not in the archiveThis patch adds an additional parameter min_reclaimable_blks to the nilfs_reclaim_params structure. This parameter specifies the minimum number of reclaimable blocks in a segment, before it can be cleaned. If a segment is below this threshold, it is considered to be not worth cleaning, because all the live blocks would need to be moved to a new segment, which is expensive, and the number of reclaimable blocks is too low. But it is still necessary to update the segment usage information to turn the old segment into a new one.
This is basically a shortcut to cleaning the segment. It is still necessary to read the segment summary information, but the writing of the live blocks can be skipped if it's not worth it.
This optimization can be enabled and disabled by the use_set_suinfo switch in the configuration file. If the kernel doesn't support the set_suinfo ioctl it returns the error number ENOTTY, which also permanently disables the optimization.
--- include/nilfs_gc.h | 11 +++---- lib/gc.c | 74 ++++++++++++++++++++++++++++++++++++++++++++---- sbin/cleanerd/cleanerd.c | 38 +++++++++++++++++++------ 3 files changed, 104 insertions(+), 19 deletions(-)
include/nilfs_gc.h +6 -5
@@ -15,20 +15,21 @@#include "nilfs.h" /* flags for nilfs_reclaim_params struct */ -#define NILFS_RECLAIM_PARAM_PROTSEQ (1UL << 0) -#define NILFS_RECLAIM_PARAM_PROTCNO (1UL << 1) -#define __NR_NILFS_RECLAIM_PARAMS 2 +#define NILFS_RECLAIM_PARAM_PROTSEQ (1UL << 0) +#define NILFS_RECLAIM_PARAM_PROTCNO (1UL << 1) +#define NILFS_RECLAIM_PARAM_MIN_RECLAIMABLE_BLKS (1UL << 2) +#define __NR_NILFS_RECLAIM_PARAMS 3/** * struct nilfs_reclaim_params - structure to specify GC parameters * @flags: flags of valid fields -* @reserved: padding bytes +* @min_reclaimable_blks: minimum number of reclaimable blocks * @protseq: start of sequence number of protected segments * @protcno: start number of checkpoint to be protected */ struct nilfs_reclaim_params {unsigned long flags; -unsigned long reserved; +unsigned long min_reclaimable_blks;__u64 protseq;nilfs_cno_t protcno; };
lib/gc.c +68 -6
124 lines not on this page · raw message
sbin/cleanerd/cleanerd.c +30 -8
@@ -1392,15 +1392,17 @@ static void nilfs_cleanerd_progress(struct nilfs_cleanerd *cleanerd, int nsegs)static int nilfs_cleanerd_clean_segments (struct nilfs_cleanerd *cleanerd,__u64 *segnums,size_t nsegs,__u64 protseq,__u64 prottime, -size_t *ncleaned) +size_t *ndone) {struct nilfs_reclaim_params params;struct nilfs_reclaim_stat stat; -int ret, i; +int ret, i, sumsegs; - params.flags = -NILFS_RECLAIM_PARAM_PROTSEQ |NILFS_RECLAIM_PARAM_PROTCNO ; - params.reserved =0 ; + params.flags =NILFS_RECLAIM_PARAM_PROTSEQ | +NILFS_RECLAIM_PARAM_PROTCNO | +NILFS_RECLAIM_PARAM_MIN_RECLAIMABLE_BLKS ; + params.min_reclaimable_blks = +nilfs_cleanerd_min_reclaimable_blocks (cleanerd); params.protseq = protseq; ret = nilfs_cnoconv_time2cno(cleanerd->cnoconv, prottime,
@@ -1418,20 +1420,40 @@ static int nilfs_cleanerd_clean_segments(struct nilfs_cleanerd *cleanerd,if (errno ==ENOMEM ) {nilfs_cleanerd_reduce_ncleansegs_for_retry (cleanerd); cleanerd->fallback =1 ; - *ncleaned =0 ; + *ndone =0 ; ret =0 ; } goto out; } + *ndone =0 ; +if (stat.cleaned_segs >0 ) {for (i =0 ; i < stat.cleaned_segs; i++)syslog (LOG_DEBUG ,"segment %llu cleaned" , (unsigned long long )segnums[i]); +nilfs_cleanerd_progress (cleanerd, stat.cleaned_segs); cleanerd->fallback =0 ; cleanerd->retry_cleaning =0 ; - }else { + + *ndone += stat.cleaned_segs; + } + +if (stat.deferred_segs >0 ) { + sumsegs = stat.cleaned_segs + stat.deferred_segs; +for (i = stat.cleaned_segs; i < sumsegs; i++) +syslog (LOG_DEBUG ,"segment %llu deferred" , + (unsigned long long )segnums[i]); + +nilfs_cleanerd_progress (cleanerd, stat.deferred_segs); + cleanerd->fallback =0 ; + cleanerd->retry_cleaning =0 ; + + *ndone += stat.deferred_segs; + } + +if (*ndone ==0 ) {syslog (LOG_DEBUG ,"no segments cleaned" ); if (!cleanerd->retry_cleaning &&
@@ -1445,7 +1467,7 @@ static int nilfs_cleanerd_clean_segments(struct nilfs_cleanerd *cleanerd, cleanerd->retry_cleaning =0 ; } } - *ncleaned = stat.cleaned_segs; + out:return ret; }
Signature · 6 lines
1.8.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 6/6 nilfs-utils: add a no_timeout flag to enable faster loop
In reply to a message not in the archiveThis patch adds a flag, that enables the GC to skip the timeout in certain situations. For example if the cleaning of some segments was deferred to a later time, then no real progress has been made. Apart from reading a few summary blocks, no data was read or written to disk. In this situation it makes sense to skip the normal timeout once and immediately try to clean the next set of segments.
Unfortunately it is not possible, to directly continue the cleaning loop, because this would lead to an unresponsive GC process. Therefore the timeout is simply set to 0 seconds.
--- sbin/cleanerd/cleanerd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sbin/cleanerd/cleanerd.c +8 -1
@@ -141,6 +141,7 @@ const static struct option long_option[] = {* @running: running state * @fallback: fallback state * @retry_cleaning: retrying reclamation for protected segments +* @no_timeout: the next timeout will be 0 seconds * @ncleansegs: number of semgents cleaned per cycle * @cleaning_interval: cleaning interval * @target: target time for sleeping
@@ -169,6 +170,7 @@ struct nilfs_cleanerd {int running;int fallback;int retry_cleaning; +int no_timeout;int shutdown;long ncleansegs;struct timeval cleaning_interval;
@@ -896,7 +898,7 @@ static int nilfs_cleanerd_recalc_interval(struct nilfs_cleanerd *cleanerd, interval =nilfs_cleanerd_cleaning_interval (cleanerd);/* timercmp() does not work for '>=' or '<='. */ /* curr >= target */ - if (!timercmp(&curr, &cleanerd->target, <)) { + if (!timercmp(&curr, &cleanerd->target, <) || cleanerd->no_timeout) { cleanerd->timeout.tv_sec =0 ; cleanerd->timeout.tv_usec =0 ;timeradd (&curr, interval, &cleanerd->target);
@@ -1450,6 +1452,9 @@ static int nilfs_cleanerd_clean_segments(struct nilfs_cleanerd *cleanerd, cleanerd->fallback =0 ; cleanerd->retry_cleaning =0 ; +if (!stat.cleaned_segs) + cleanerd->no_timeout =1 ; + *ndone += stat.deferred_segs; }
@@ -1523,6 +1528,8 @@ static int nilfs_cleanerd_clean_loop(struct nilfs_cleanerd *cleanerd)nilfs_cleanerd_clean_check_pause (cleanerd);while (!cleanerd->shutdown) { + cleanerd->no_timeout =0 ; +if (sigprocmask (SIG_BLOCK , &sigset,NULL ) <0 ) {syslog (LOG_ERR ,"cannot set signal mask: %m" );return -1 ;
Signature · 6 lines
1.8.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Ryusuke Konishi
AppliedQuoted 28 lines · Andreas Rohner
Hi,
This patch set adds an optimized version of
nilfs_xreclaim_segments, which has an additional parametermin_reclaimable_blks. This parameter specifies the minimum number of reclaimable blocks in a segment, before it can be cleaned. If a segment is below this threshold, it is considered to be not worth cleaning, because all the live blocks would need to be moved to a new segment, which is expensive, and the number of reclaimable blocks is too low. But it is still necessary to update the segment usage information to turn the old segment into a new one.This is basically a shortcut to cleaning the segment. It is still necessary to read the segment summary information, but the writing of the live blocks can be skipped if it's not worth it.
Additionally new options are introduced for the configuration file and nilfs-clean to allow the user to specify the threshold.
This is potentially useful for all gc policies, but it is especially beneficial for the timestamp policy. Lets assume for example a NILFS2 volume with 20% static files and lets assume these static files are in the oldest segments. The current timestamp policy will select the oldest segments and, since the data is static, move them mostly unchanged to new segments. After a while they will become the oldest segments again. Then timestamp will move them again. These moving operations are expensive and unnecessary.
Quoted 2 lines
Regards,
Andreas Rohner
Applied. Thank you for your effort!
Ryusuke Konishi
Quoted 53 lines
---
v5->v6(based on review by Ryusuke Konishi)
* Add support for percent in nilfs-clean -m argument
* Change location ofnilfs_opt_test_set_suinfocheck
* Change interpretation of stat.cleaned_segs and stat.deferred_segs to be not exclusive
v4->v5(based on review by Ryusuke Konishi)
* Add missing comments and documentation
* Fixnilfs_set_suinforeturn value
* Fix coding style issues
* Return error if invalidmin_reclaimable_blocksis sent from nilfs-clean command
* Usenilfs_vectorinstead of malloc innilfs_xreclaim_segment
* Renamenilfs_reclaim_paramsflag toNILFS_RECLAIM_PARAM_MIN_RECLAIMABLE_BLKS
* Changed the interpretation ofdeferred_segsinnilfs_reclaim_stat
v3->v4(based on review by Ryusuke Konishi)
* nilfs-utils: Rebase on refactorednilfs_reclaim_segments(by Ryusuke Konishi)
* nilfs-utils: Addno_timeoutif cleaning was deferred
v2->v3(based on review by Ryusuke Konishi)
* Alignment innilfs_suinfo_update
* Add missing comments
* nilfs2: Extra validity checks innilfs_sufile_set_suinfo
* nilfs2: Updatesh_ncleansegs,sh_ndirtysegsif flags change
* nilfs2: Fix bugs innilfs_sufile_set_suinfo
* nilfs2: Use vmalloc instead ofioctl_wrap_copy
* nilfs-utils: Separatenilfs_relaim_segments_with_threshold
* nilfs-utils: Allow different units formin_reclaimable_blocks
* nilfs-utils: Introduce flag to disable the optimization
* nilfs-utils: Disable optimization if kernel retruns ENOTTY
* nilfs-utils: Remove EGCTRYAGAIN error return code
* nilfs-utils: Rename option tomin_reclaimable_blocks
v1->v2(based on review by Ryusuke Konishi)
* Implementation ofNILFS_IOCTL_SET_SUINFO
* Addedmc_min_free_blocks_thresholdconfig option
(if clean segments <min_clean_segments)
* Added new command line param for nilfs-clean
* Update man- and config-file
--
Andreas Rohner (6):
nilfs-utils: cldconfig add an option to set min. reclaimable blocks
nilfs-utils: addNILFS_OPT_SET_SUINFO
nilfs-utils: nilfs-clean add cmdline param min-reclaimable-blocks
nilfs-utils: add suport forNILFS_IOCTL_SET_SUINFOioctl
nilfs-utils: add optimized version ofnilfs_xreclaim_segments
nilfs-utils: add ano_timeoutflag to enable faster loop
Quoted 22 lines
include/nilfs.h | 9 +- include/nilfs2_fs.h | 44 ++++++++++ include/nilfs_cleaner.h | 43 +++++++--- include/nilfs_gc.h | 11 +-- lib/gc.c | 74 +++++++++++++++-- lib/nilfs.c | 59 +++++++++++++ man/nilfs-clean.8 | 7 ++ man/nilfs_cleanerd.conf.5 | 22 +++++ sbin/cleanerd/cldconfig.c | 169 ++++++++++++++++++++++++++++---------- sbin/cleanerd/cldconfig.h | 12 +++ sbin/cleanerd/cleanerd.c | 100 ++++++++++++++++++++-- sbin/cleanerd/nilfs_cleanerd.conf | 20 +++++ sbin/nilfs-clean/nilfs-clean.c | 58 +++++++++++-- 13 files changed, 549 insertions(+), 79 deletions(-)Signature · 6 lines
1.8.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html