vfs: export lseek_execute() to modules
For those file systems(btrfs/ext4/ocfs2/tmpfs) that support SEEK_DATA/SEEK_HOLE functions, we end up handling the similar matter in lseek_execute() to update the current file offset to the desired offset if it is valid, ceph also does the simliar things at ceph_llseek(). To reduce the duplications, this patch make lseek_execute() public accessible so that we can call it directly from the underlying file systems. Thanks Dave Chinner for this suggestion. [AV: call it vfs_setpos(), don't bring the removed 'inode' argument back] v2->v1: - Add kernel-doc comments for lseek_execute() - Call lseek_execute() in ceph->llseek() Signed-off-by: Jie Liu <jeff.liu@oracle.com> Cc: Dave Chinner <dchinner@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andi Kleen <andi@firstfloor.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Chris Mason <chris.mason@fusionio.com> Cc: Josef Bacik <jbacik@fusionio.com> Cc: Ben Myers <bpm@sgi.com> Cc: Ted Tso <tytso@mit.edu> Cc: Hugh Dickins <hughd@google.com> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Sage Weil <sage@inktank.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@ -494,17 +494,7 @@ static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
|
||||
if (dataoff > isize)
|
||||
return -ENXIO;
|
||||
|
||||
if (dataoff < 0 && !(file->f_mode & FMODE_UNSIGNED_OFFSET))
|
||||
return -EINVAL;
|
||||
if (dataoff > maxsize)
|
||||
return -EINVAL;
|
||||
|
||||
if (dataoff != file->f_pos) {
|
||||
file->f_pos = dataoff;
|
||||
file->f_version = 0;
|
||||
}
|
||||
|
||||
return dataoff;
|
||||
return vfs_setpos(file, dataoff, maxsize);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -580,17 +570,7 @@ static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
|
||||
if (holeoff > isize)
|
||||
holeoff = isize;
|
||||
|
||||
if (holeoff < 0 && !(file->f_mode & FMODE_UNSIGNED_OFFSET))
|
||||
return -EINVAL;
|
||||
if (holeoff > maxsize)
|
||||
return -EINVAL;
|
||||
|
||||
if (holeoff != file->f_pos) {
|
||||
file->f_pos = holeoff;
|
||||
file->f_version = 0;
|
||||
}
|
||||
|
||||
return holeoff;
|
||||
return vfs_setpos(file, holeoff, maxsize);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user