From: Marc Dionne Date: Sat, 8 Nov 2008 16:49:25 +0000 (+0000) Subject: linux-new-aop-20081108 X-Git-Tag: openafs-devel-1_5_61~702 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=041f09e17b7e1760a968c0e38f52d7feac2862ba linux-new-aop-20081108 LICENSE IPL10 FIXES 123580 support for 2.6.28 --- diff --git a/acinclude.m4 b/acinclude.m4 index ebd18d8..18d2524 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -811,6 +811,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_EXPORTS_FIND_TASK_BY_PID LINUX_EXPORTS_PROC_ROOT_FS LINUX_HAVE_CURRENT_KERNEL_TIME + LINUX_HAVE_WRITE_BEGIN_AOP LINUX_HAVE_BDI_INIT LINUX_KMEM_CACHE_INIT LINUX_HAVE_KMEM_CACHE_T diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index bb3e499..4910004 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -57,6 +57,7 @@ extern struct backing_dev_info afs_backing_dev_info; #endif extern struct vcache *afs_globalVp; +extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp); #if defined(AFS_LINUX26_ENV) /* Some uses of BKL are perhaps not needed for bypass or memcache-- * why don't we try it out? */ @@ -2076,7 +2077,7 @@ afs_linux_permission(struct inode *ip, int mode) return -code; } -#if defined(AFS_LINUX24_ENV) +#if defined(AFS_LINUX24_ENV) && !defined(HAVE_WRITE_BEGIN) static int afs_linux_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to) @@ -2103,10 +2104,40 @@ afs_linux_prepare_write(struct file *file, struct page *page, unsigned from, #endif return 0; } +#endif -extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp); +#if defined(HAVE_WRITE_BEGIN) +static int +afs_linux_write_end(struct file *file, struct address_space *mapping, + loff_t pos, unsigned len, unsigned copied, + struct page *page, void *fsdata) +{ + int code; + pgoff_t index = pos >> PAGE_CACHE_SHIFT; + unsigned from = pos & (PAGE_CACHE_SIZE - 1); + + code = afs_linux_writepage_sync(file->f_dentry->d_inode, page, + from, copied); + unlock_page(page); + page_cache_release(page); + return code; +} + +static int +afs_linux_write_begin(struct file *file, struct address_space *mapping, + loff_t pos, unsigned len, unsigned flags, + struct page **pagep, void **fsdata) +{ + struct page *page; + pgoff_t index = pos >> PAGE_CACHE_SHIFT; + page = __grab_cache_page(mapping, index); + *pagep = page; + + return 0; +} #endif + static struct inode_operations afs_file_iops = { #if defined(AFS_LINUX26_ENV) .permission = afs_linux_permission, @@ -2131,8 +2162,13 @@ static struct address_space_operations afs_file_aops = { .readpages = afs_linux_readpages, #endif .writepage = afs_linux_writepage, - .commit_write = afs_linux_commit_write, - .prepare_write = afs_linux_prepare_write, +#if defined (HAVE_WRITE_BEGIN) + .write_begin = afs_linux_write_begin, + .write_end = afs_linux_write_end, +#else + .commit_write = afs_linux_commit_write, + .prepare_write = afs_linux_prepare_write, +#endif }; #endif diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 1d95461..6b24ce5 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -1104,3 +1104,16 @@ AC_DEFUN([LINUX_HAVE_BDI_INIT], [ if test "x$ac_cv_linux_bdi_init" = "xyes"; then AC_DEFINE([HAVE_BDI_INIT], 1, [define if your kernel has a bdi_init()]) fi]) + +AC_DEFUN([LINUX_HAVE_WRITE_BEGIN_AOP], [ + AC_MSG_CHECKING([for linux write_begin() address space op]) + AC_CACHE_VAL([ac_cv_linux_write_begin], [ + AC_TRY_KBUILD( +[#include ], +[simple_write_begin(NULL, NULL, 0, 0, 0, NULL, NULL);], + ac_cv_linux_write_begin=yes, + ac_cv_linux_write_begin=no)]) + AC_MSG_RESULT($ac_cv_linux_write_begin) + if test "x$ac_cv_linux_write_begin" = "xyes"; then + AC_DEFINE([HAVE_WRITE_BEGIN], 1, [define if your kernel has a write_begin() address space op]) + fi])