scoutfs: provide cluster safe ->llseek

Without this we return -ESPIPE when a process tries to seek on a regular
file.

Signed-off-by: Mark Fasheh <mfasheh@versity.com>
[zab: adapted to new lock call]
Signed-off-by: Zach Brown <zab@zabbo.net>
This commit is contained in:
Mark Fasheh
2017-08-30 10:38:00 -07:00
committed by Zach Brown
parent 1bcad2e9cc
commit c4e7b5a6e9
3 changed files with 40 additions and 1 deletions
+1 -1
View File
@@ -1295,7 +1295,7 @@ const struct file_operations scoutfs_file_fops = {
.aio_write = scoutfs_file_aio_write,
.unlocked_ioctl = scoutfs_ioctl,
.fsync = scoutfs_file_fsync,
.llseek = generic_file_llseek,
.llseek = scoutfs_file_llseek,
};
+38
View File
@@ -104,3 +104,41 @@ int scoutfs_permission(struct inode *inode, int mask)
return ret;
}
loff_t scoutfs_file_llseek(struct file *file, loff_t offset, int whence)
{
struct inode *inode = file->f_mapping->host;
struct super_block *sb = inode->i_sb;
struct scoutfs_lock *lock = NULL;
int ret = 0;
switch (whence) {
case SEEK_END:
case SEEK_DATA:
case SEEK_HOLE:
/*
* These require a lock and inode refresh as they
* reference i_size.
*
* XXX: SEEK_DATA/SEEK_HOLE can search our extent
* items instead of relying on generic_file_llseek()
* trickery.
*/
ret = scoutfs_lock_inode(sb, DLM_LOCK_PR,
SCOUTFS_LKF_REFRESH_INODE, inode,
&lock);
case SEEK_SET:
case SEEK_CUR:
/* No lock required, fall through to the generic helper */
break;
default:
ret = -EINVAL;
}
if (ret == 0)
offset = generic_file_llseek(file, offset, whence);
scoutfs_unlock(sb, lock, DLM_LOCK_PR);
return ret ? ret : offset;
}
+1
View File
@@ -6,5 +6,6 @@ ssize_t scoutfs_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
ssize_t scoutfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos);
int scoutfs_permission(struct inode *inode, int mask);
loff_t scoutfs_file_llseek(struct file *file, loff_t offset, int whence);
#endif /* _SCOUTFS_FILE_H_ */