| [2060] | 1 | From: Marc Dionne <marc.c.dionne@gmail.com> | 
|---|
|  | 2 | Date: Fri, 2 Sep 2011 21:56:58 +0000 (-0400) | 
|---|
|  | 3 | Subject: Linux: 3.1: adapt to fsync changes | 
|---|
|  | 4 | X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=81f28004415ae07f2e3a1320da632cbd52c96b25;hp=ef492dc1e1a1809a910fbf07140b26c4924957c5 | 
|---|
|  | 5 |  | 
|---|
|  | 6 | Linux: 3.1: adapt to fsync changes | 
|---|
|  | 7 |  | 
|---|
|  | 8 | The fsync file operation gets new arguments to specify a range. | 
|---|
|  | 9 | Add a configure test to check for the API change. | 
|---|
|  | 10 |  | 
|---|
|  | 11 | The inode lock is also pushed down into the operation, so we need | 
|---|
|  | 12 | to take it ourselves to keep the original behaviour. | 
|---|
|  | 13 |  | 
|---|
|  | 14 | Reviewed-on: http://gerrit.openafs.org/5332 | 
|---|
|  | 15 | Tested-by: BuildBot <buildbot@rampaginggeek.com> | 
|---|
|  | 16 | Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk> | 
|---|
|  | 17 | Reviewed-by: Derrick Brashear <shadow@dementix.org> | 
|---|
|  | 18 | (cherry picked from commit cbaefa266d433af3b9a082a360e23a42f161d80f) | 
|---|
|  | 19 |  | 
|---|
|  | 20 | Change-Id: Idb6770204b014c62a8611548509240f8b5f950bc | 
|---|
|  | 21 | --- | 
|---|
|  | 22 |  | 
|---|
|  | 23 | diff --git a/acinclude.m4 b/acinclude.m4 | 
|---|
|  | 24 | index 3ff4551..35f2200 100644 | 
|---|
|  | 25 | --- a/acinclude.m4 | 
|---|
|  | 26 | +++ b/acinclude.m4 | 
|---|
|  | 27 | @@ -920,6 +920,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) | 
|---|
|  | 28 | LINUX_DOP_D_REVALIDATE_TAKES_NAMEIDATA | 
|---|
|  | 29 | LINUX_FOP_F_FLUSH_TAKES_FL_OWNER_T | 
|---|
|  | 30 | LINUX_FOP_F_FSYNC_TAKES_DENTRY | 
|---|
|  | 31 | +                LINUX_FOP_F_FSYNC_TAKES_RANGE | 
|---|
|  | 32 | LINUX_AOP_WRITEBACK_CONTROL | 
|---|
|  | 33 | LINUX_FS_STRUCT_FOP_HAS_SPLICE | 
|---|
|  | 34 | LINUX_KERNEL_POSIX_LOCK_FILE_WAIT_ARG | 
|---|
|  | 35 | diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c | 
|---|
|  | 36 | index 696146b..019b568 100644 | 
|---|
|  | 37 | --- a/src/afs/LINUX/osi_vnodeops.c | 
|---|
|  | 38 | +++ b/src/afs/LINUX/osi_vnodeops.c | 
|---|
|  | 39 | @@ -425,6 +425,8 @@ afs_linux_release(struct inode *ip, struct file *fp) | 
|---|
|  | 40 | static int | 
|---|
|  | 41 | #if defined(FOP_FSYNC_TAKES_DENTRY) | 
|---|
|  | 42 | afs_linux_fsync(struct file *fp, struct dentry *dp, int datasync) | 
|---|
|  | 43 | +#elif defined(FOP_FSYNC_TAKES_RANGE) | 
|---|
|  | 44 | +afs_linux_fsync(struct file *fp, loff_t start, loff_t end, int datasync) | 
|---|
|  | 45 | #else | 
|---|
|  | 46 | afs_linux_fsync(struct file *fp, int datasync) | 
|---|
|  | 47 | #endif | 
|---|
|  | 48 | @@ -433,9 +435,15 @@ afs_linux_fsync(struct file *fp, int datasync) | 
|---|
|  | 49 | struct inode *ip = FILE_INODE(fp); | 
|---|
|  | 50 | cred_t *credp = crref(); | 
|---|
|  | 51 |  | 
|---|
|  | 52 | +#if defined(FOP_FSYNC_TAKES_RANGE) | 
|---|
|  | 53 | +    mutex_lock(&ip->i_mutex); | 
|---|
|  | 54 | +#endif | 
|---|
|  | 55 | AFS_GLOCK(); | 
|---|
|  | 56 | code = afs_fsync(VTOAFS(ip), credp); | 
|---|
|  | 57 | AFS_GUNLOCK(); | 
|---|
|  | 58 | +#if defined(FOP_FSYNC_TAKES_RANGE) | 
|---|
|  | 59 | +    mutex_unlock(&ip->i_mutex); | 
|---|
|  | 60 | +#endif | 
|---|
|  | 61 | crfree(credp); | 
|---|
|  | 62 | return afs_convert_code(code); | 
|---|
|  | 63 |  | 
|---|
|  | 64 | diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 | 
|---|
|  | 65 | index 2292f81..35082b3 100644 | 
|---|
|  | 66 | --- a/src/cf/linux-test4.m4 | 
|---|
|  | 67 | +++ b/src/cf/linux-test4.m4 | 
|---|
|  | 68 | @@ -414,6 +414,22 @@ struct dentry _d; | 
|---|
|  | 69 | ]) | 
|---|
|  | 70 |  | 
|---|
|  | 71 |  | 
|---|
|  | 72 | +int (*fsync) (struct file *, loff_t start, loff_t end, int datasync); | 
|---|
|  | 73 | + | 
|---|
|  | 74 | +AC_DEFUN([LINUX_FOP_F_FSYNC_TAKES_RANGE], [ | 
|---|
|  | 75 | +  AC_CHECK_LINUX_BUILD([whether file_operations.fsync takes a range], | 
|---|
|  | 76 | +                      [ac_cv_linux_func_f_fsync_takes_range], | 
|---|
|  | 77 | +                      [#include <linux/fs.h>], | 
|---|
|  | 78 | +[struct inode _inode; | 
|---|
|  | 79 | +struct file _file; | 
|---|
|  | 80 | +loff_t start, end; | 
|---|
|  | 81 | +(void)_inode.i_fop->fsync(&_file, start, end, 0);], | 
|---|
|  | 82 | +                      [FOP_FSYNC_TAKES_RANGE], | 
|---|
|  | 83 | +                      [define if your fops.fsync takes range arguments], | 
|---|
|  | 84 | +                      []) | 
|---|
|  | 85 | +]) | 
|---|
|  | 86 | + | 
|---|
|  | 87 | + | 
|---|
|  | 88 | AC_DEFUN([LINUX_HAVE_KMEM_CACHE_T], [ | 
|---|
|  | 89 | AC_CHECK_LINUX_BUILD([whether kmem_cache_t exists], | 
|---|
|  | 90 | [ac_cv_linux_have_kmem_cache_t], | 
|---|