From afa30e60fe5e0b7ef6e3f1faa313372d96d18943 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Tue, 10 Oct 2017 16:22:39 -0500 Subject: [PATCH] scoutfs: use inclusive range for scoutfs_data_truncate_items() This makes calling it for truncate less cumbersome - we can safely use ~0ULL for the end point now. Signed-off-by: Mark Fasheh --- kmod/src/data.c | 11 +++++------ kmod/src/data.h | 2 +- kmod/src/ioctl.c | 3 ++- kmod/src/scoutfs_trace.h | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/kmod/src/data.c b/kmod/src/data.c index e42fd0eb..4c8b88bb 100644 --- a/kmod/src/data.c +++ b/kmod/src/data.c @@ -594,7 +594,8 @@ out: i++, iblock++) /* - * Free blocks inside the specified logical block range. + * Free blocks inside the logical block range from 'iblock' to 'last', + * inclusive. * * If 'offline' is given then blocks are freed an offline mapping is * left behind. @@ -604,7 +605,7 @@ out: * partial progress. */ int scoutfs_data_truncate_items(struct super_block *sb, u64 ino, u64 iblock, - u64 len, bool offline, + u64 last, bool offline, struct scoutfs_lock *lock) { struct scoutfs_key_buf last_key; @@ -617,21 +618,19 @@ int scoutfs_data_truncate_items(struct super_block *sb, u64 ino, u64 iblock, bool dirtied; bool modified; u64 blkno; - u64 last; int bytes; int ret = 0; int i; - trace_scoutfs_data_truncate_items(sb, iblock, len, offline); + trace_scoutfs_data_truncate_items(sb, iblock, last, offline); - if (WARN_ON_ONCE(iblock + len < iblock)) + if (WARN_ON_ONCE(last < iblock)) return -EINVAL; map = kmalloc(sizeof(struct block_mapping), GFP_NOFS); if (!map) return -ENOMEM; - last = iblock + len - 1; init_mapping_key(&last_key, &last_bmk, ino, last); while (iblock <= last) { diff --git a/kmod/src/data.h b/kmod/src/data.h index 0dcd23a6..a305ad2e 100644 --- a/kmod/src/data.h +++ b/kmod/src/data.h @@ -5,7 +5,7 @@ extern const struct address_space_operations scoutfs_file_aops; extern const struct file_operations scoutfs_file_fops; int scoutfs_data_truncate_items(struct super_block *sb, u64 ino, u64 iblock, - u64 len, bool offline, + u64 last, bool offline, struct scoutfs_lock *lock); int scoutfs_data_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 len); diff --git a/kmod/src/ioctl.c b/kmod/src/ioctl.c index 0b8df1ad..9906e617 100644 --- a/kmod/src/ioctl.c +++ b/kmod/src/ioctl.c @@ -381,7 +381,8 @@ static long scoutfs_ioc_release(struct file *file, unsigned long arg) truncate_inode_pages_range(&inode->i_data, start, end_inc); ret = scoutfs_data_truncate_items(sb, scoutfs_ino(inode), args.block, - args.count, true, lock); + args.block + args.count - 1, true, + lock); out: scoutfs_unlock(sb, lock, DLM_LOCK_EX); mutex_unlock(&inode->i_mutex); diff --git a/kmod/src/scoutfs_trace.h b/kmod/src/scoutfs_trace.h index 8e0fd843..8e3d4eba 100644 --- a/kmod/src/scoutfs_trace.h +++ b/kmod/src/scoutfs_trace.h @@ -493,26 +493,26 @@ TRACE_EVENT(scoutfs_data_get_cursor, ); TRACE_EVENT(scoutfs_data_truncate_items, - TP_PROTO(struct super_block *sb, __u64 iblock, __u64 len, int offline), + TP_PROTO(struct super_block *sb, __u64 iblock, __u64 last, int offline), - TP_ARGS(sb, iblock, len, offline), + TP_ARGS(sb, iblock, last, offline), TP_STRUCT__entry( __field(__u64, fsid) __field(__u64, iblock) - __field(__u64, len) + __field(__u64, last) __field(int, offline) ), TP_fast_assign( __entry->fsid = FSID_ARG(sb); __entry->iblock = iblock; - __entry->len = len; + __entry->last = last; __entry->offline = offline; ), - TP_printk(FSID_FMT" iblock %llu len %llu offline %u", __entry->fsid, - __entry->iblock, __entry->len, __entry->offline) + TP_printk(FSID_FMT" iblock %llu last %llu offline %u", __entry->fsid, + __entry->iblock, __entry->last, __entry->offline) ); TRACE_EVENT(scoutfs_data_set_segno_free,