X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=module%2Fzfs%2Fzpl_file.c;h=299589193e5ca513a5e1baaa9b6d08d70d8d07f0;hb=570d6edf1d94917aab49c5755027d05b3c7bcd43;hp=5ac41c9d24e9747a649e7e28e1a8bb5fb731e577;hpb=cb2d19010d8fbcf6c22585cd8763fad3ba7db724;p=zfs.git diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c index 5ac41c9..2995891 100644 --- a/module/zfs/zpl_file.c +++ b/module/zfs/zpl_file.c @@ -52,6 +52,9 @@ zpl_release(struct inode *ip, struct file *filp) cred_t *cr = CRED(); int error; + if (ITOZ(ip)->z_atime_dirty) + mark_inode_dirty(ip); + crhold(cr); error = -zfs_close(ip, filp->f_flags, cr); crfree(cr); @@ -235,6 +238,28 @@ zpl_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos) return (wrote); } +static loff_t +zpl_llseek(struct file *filp, loff_t offset, int whence) +{ +#if defined(SEEK_HOLE) && defined(SEEK_DATA) + if (whence == SEEK_DATA || whence == SEEK_HOLE) { + struct inode *ip = filp->f_mapping->host; + loff_t maxbytes = ip->i_sb->s_maxbytes; + loff_t error; + + spl_inode_lock(ip); + error = -zfs_holey(ip, whence, &offset); + if (error == 0) + error = lseek_execute(filp, ip, offset, maxbytes); + spl_inode_unlock(ip); + + return (error); + } +#endif /* SEEK_HOLE && SEEK_DATA */ + + return generic_file_llseek(filp, offset, whence); +} + /* * It's worth taking a moment to describe how mmap is implemented * for zfs because it differs considerably from other Linux filesystems. @@ -357,21 +382,16 @@ zpl_putpage(struct page *pp, struct writeback_control *wbc, void *data) ASSERT(PageLocked(pp)); ASSERT(!PageWriteback(pp)); + ASSERT(!(current->flags & PF_NOFS)); /* - * Disable the normal reclaim path for zpl_putpage(). This - * ensures that all memory allocations under this call path - * will never enter direct reclaim. If this were to happen - * the VM might try to write out additional pages by calling - * zpl_putpage() again resulting in a deadlock. + * Annotate this call path with a flag that indicates that it is + * unsafe to use KM_SLEEP during memory allocations due to the + * potential for a deadlock. KM_PUSHPAGE should be used instead. */ - if (current->flags & PF_MEMALLOC) { - (void) zfs_putpage(mapping->host, pp, wbc); - } else { - current->flags |= PF_MEMALLOC; - (void) zfs_putpage(mapping->host, pp, wbc); - current->flags &= ~PF_MEMALLOC; - } + current->flags |= PF_NOFS; + (void) zfs_putpage(mapping->host, pp, wbc); + current->flags &= ~PF_NOFS; return (0); } @@ -438,6 +458,27 @@ zpl_fallocate(struct file *filp, int mode, loff_t offset, loff_t len) } #endif /* HAVE_FILE_FALLOCATE */ +static long +zpl_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + case ZFS_IOC_GETFLAGS: + case ZFS_IOC_SETFLAGS: + return (-EOPNOTSUPP); + default: + return (-ENOTTY); + } +} + +#ifdef CONFIG_COMPAT +static long +zpl_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + return zpl_ioctl(filp, cmd, arg); +} +#endif /* CONFIG_COMPAT */ + + const struct address_space_operations zpl_address_space_operations = { .readpages = zpl_readpages, .readpage = zpl_readpage, @@ -448,15 +489,18 @@ const struct address_space_operations zpl_address_space_operations = { const struct file_operations zpl_file_operations = { .open = zpl_open, .release = zpl_release, - .llseek = generic_file_llseek, + .llseek = zpl_llseek, .read = zpl_read, .write = zpl_write, - .readdir = zpl_readdir, .mmap = zpl_mmap, .fsync = zpl_fsync, #ifdef HAVE_FILE_FALLOCATE .fallocate = zpl_fallocate, #endif /* HAVE_FILE_FALLOCATE */ + .unlocked_ioctl = zpl_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = zpl_compat_ioctl, +#endif }; const struct file_operations zpl_dir_file_operations = { @@ -464,4 +508,8 @@ const struct file_operations zpl_dir_file_operations = { .read = generic_read_dir, .readdir = zpl_readdir, .fsync = zpl_fsync, + .unlocked_ioctl = zpl_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = zpl_compat_ioctl, +#endif };