@@ -749,21 +749,45 @@ int afs_flush(struct file *file, fl_owner_t id)
749749 * notification that a previously read-only page is about to become writable
750750 * - if it returns an error, the caller will deliver a bus error signal
751751 */
752- int afs_page_mkwrite (struct vm_area_struct * vma , struct page * page )
752+ int afs_page_mkwrite (struct vm_fault * vmf )
753753{
754- struct afs_vnode * vnode = AFS_FS_I (vma -> vm_file -> f_mapping -> host );
754+ struct file * file = vmf -> vma -> vm_file ;
755+ struct inode * inode = file_inode (file );
756+ struct afs_vnode * vnode = AFS_FS_I (inode );
757+ unsigned long priv ;
755758
756759 _enter ("{{%x:%u}},{%lx}" ,
757- vnode -> fid .vid , vnode -> fid .vnode , page -> index );
760+ vnode -> fid .vid , vnode -> fid .vnode , vmf -> page -> index );
758761
759- /* wait for the page to be written to the cache before we allow it to
760- * be modified */
762+ sb_start_pagefault (inode -> i_sb );
763+
764+ /* Wait for the page to be written to the cache before we allow it to
765+ * be modified. We then assume the entire page will need writing back.
766+ */
761767#ifdef CONFIG_AFS_FSCACHE
762- fscache_wait_on_page_write (vnode -> cache , page );
768+ fscache_wait_on_page_write (vnode -> cache , vmf -> page );
763769#endif
764770
765- _leave (" = 0" );
766- return 0 ;
771+ if (PageWriteback (vmf -> page ) &&
772+ wait_on_page_bit_killable (vmf -> page , PG_writeback ) < 0 )
773+ return VM_FAULT_RETRY ;
774+
775+ if (lock_page_killable (vmf -> page ) < 0 )
776+ return VM_FAULT_RETRY ;
777+
778+ /* We mustn't change page->private until writeback is complete as that
779+ * details the portion of the page we need to write back and we might
780+ * need to redirty the page if there's a problem.
781+ */
782+ wait_on_page_writeback (vmf -> page );
783+
784+ priv = (unsigned long )PAGE_SIZE << AFS_PRIV_SHIFT ; /* To */
785+ priv |= 0 ; /* From */
786+ SetPagePrivate (vmf -> page );
787+ set_page_private (vmf -> page , priv );
788+
789+ sb_end_pagefault (inode -> i_sb );
790+ return VM_FAULT_LOCKED ;
767791}
768792
769793/*
0 commit comments