mirror of
https://github.com/versity/scoutfs.git
synced 2026-02-07 11:10:44 +00:00
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 <mfasheh@versity.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user