mirror of
https://github.com/versity/scoutfs.git
synced 2026-07-31 04:23:28 +00:00
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:
+1
-1
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
Reference in New Issue
Block a user