#if defined(AFS_LINUX26_ENV)
#define LockPage(pp) lock_page(pp)
#define UnlockPage(pp) unlock_page(pp)
+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? */
ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, page_count(pp),
ICL_TYPE_INT32, 99999);
+ ObtainReadLock(&vcp->lock);
+ if (vcp->states & CPageWrite) {
+ ReleaseReadLock(&vcp->lock);
+ AFS_GUNLOCK();
+ maybe_unlock_kernel();
+ crfree(credp);
+ kunmap(pp);
+#ifdef AFS_LINUX26_ENV
+#if defined(WRITEPAGE_ACTIVATE)
+ return WRITEPAGE_ACTIVATE;
+#else
+ return AOP_WRITEPAGE_ACTIVATE;
+#endif
+#else
+ /* should mark it dirty? */
+ return(0);
+#endif
+ }
+ ReleaseReadLock(&vcp->lock);
+
setup_uio(&tuio, &iovec, buffer, base, count, UIO_WRITE, AFS_UIOSYS);
code = afs_write(vcp, &tuio, f_flags, credp, 0);
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)
#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,
.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
if (vattr)
vattr2inode(ip, vattr);
+ ip->i_mapping->backing_dev_info = &afs_backing_dev_info;
/* Reset ops if symlink or directory. */
if (S_ISREG(ip->i_mode)) {
ip->i_op = &afs_file_iops;