From: Chaskiel M Grundman Date: Fri, 11 Mar 2005 06:51:11 +0000 (+0000) Subject: STABLE14-linux-writepage-sync-20050308 X-Git-Tag: openafs-devel-1_3_80~26 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=3d2ff936b411ab80b9ff72d80cb772c2d37bfe05;p=packages%2Fo%2Fopenafs.git STABLE14-linux-writepage-sync-20050308 FIXES 17792 "The attached patch 1) makes afs_linux_writepage_sync do the required lock_kernel and AFS_GLOCK()'s instead of making the caller do it. 2) removes the 2.4+ afs_linux_updatepage wrapper function which just calls afs_linux_writepage_sync and is only called by afs_linux_commit_write 3) removes the kmap/kunmap in afs_linux_{prepare,commit}_write on 2.6 since the caller of afs_linux_{prepare,commit}_write (do_generic_file_write) does the kmap/kunmap itself, and has since before 2.4.19 (early 2.4's do require it, and it doesn't break anything to do it twice, so !defined(AFS_LINUX26_ENV) is appropriate)" (cherry picked from commit e9084af7bfe8ef50e4ebbc57b580b8f6fffbf230) --- diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 417068751..6e0310b0c 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1565,9 +1565,7 @@ afs_linux_writepage(struct page *pp) if (pp->index >= end_index + 1 || !offset) return -EIO; do_it: - AFS_GLOCK(); status = afs_linux_writepage_sync(inode, pp, 0, offset); - AFS_GUNLOCK(); SetPageUptodate(pp); UnlockPage(pp); if (status == offset) @@ -1625,6 +1623,8 @@ afs_linux_writepage_sync(struct inode *ip, struct page *pp, base = (pp->index << PAGE_CACHE_SHIFT) + offset; credp = crref(); + lock_kernel(); + AFS_GLOCK(); afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, page_count(pp), ICL_TYPE_INT32, 99999); @@ -1651,20 +1651,14 @@ afs_linux_writepage_sync(struct inode *ip, struct page *pp, ICL_TYPE_POINTER, pp, ICL_TYPE_INT32, page_count(pp), ICL_TYPE_INT32, code); + AFS_GUNLOCK(); + unlock_kernel(); crfree(credp); kunmap(pp); return code; } -static int -afs_linux_updatepage(struct file *file, struct page *page, - unsigned long offset, unsigned int count) -{ - struct dentry *dentry = file->f_dentry; - - return afs_linux_writepage_sync(dentry->d_inode, page, offset, count); -} #else /* afs_linux_updatepage * What one would have thought was writepage - write dirty page to file. @@ -1717,12 +1711,11 @@ afs_linux_commit_write(struct file *file, struct page *page, unsigned offset, { int code; - lock_kernel(); - AFS_GLOCK(); - code = afs_linux_updatepage(file, page, offset, to - offset); - AFS_GUNLOCK(); - unlock_kernel(); + code = afs_linux_writepage_sync(file->f_dentry->d_inode, page, + offset, to - offset); +#if !defined(AFS_LINUX26_ENV) kunmap(page); +#endif return code; } @@ -1731,7 +1724,11 @@ static int afs_linux_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to) { +/* sometime between 2.4.0 and 2.4.19, the callers of prepare_write began to + call kmap directly instead of relying on us to do it */ +#if !defined(AFS_LINUX26_ENV) kmap(page); +#endif return 0; }