From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Chow Subject: nfs3_proc_write() Date: Thu, 03 Jul 2003 19:09:01 +0800 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <3F040ECD.7070108@shaolinmicro.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from [202.94.238.145] ([202.94.238.145]:21170 "EHLO mail.shaolinmicro.com") by vger.kernel.org with ESMTP id S265063AbTGCKym (ORCPT ); Thu, 3 Jul 2003 06:54:42 -0400 To: linux-fsdevel@vger.kernel.org, trond.myklebust@fys.uio.no List-Id: linux-fsdevel.vger.kernel.org Trond, I am in the middle of porting the my old nfs_swap code from 2.4.19 to 2.4.21 . I notice the interface of nfs3_proc_write() has changed, the old code uses a (char *)buffer but the new one uses a (struct page *) . When I did the following change, it didn't work. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20) u8 *buffer = (char *)kmap(page); #endif result = NFS_PROTO(inode)->write(inode, cred, &fattr, NFS_RW_SWAP|NFS_RW_SYNC, #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) offset, wsize, page, &verf); #else offset, wsize, buffer, &verf); #endif What happens is it causes an exception in kmap() which is called by xdr_kmap() . By tracing the stack with kdb, the path is as follows nfs3_proc_write-> nfs3_rpc_wrapper-> rpc_call_sync->rpc_execute->__rpc_execute->call_transmit->xprt_trnasmit-> do_xprt_transmit->xdr_kmap->kmap(inlined) By using objdump, the exact instruction which fails in the xdr_kmap() as the following len = PAGE_CACHE_SIZE; if (first_kmap) { first_kmap = 0; !!!! iov->iov_base = kmap(*ppage); !!!! } else { The exception is caused by the return page_address(page) . I've also tried a trival kmap(page) before triggering nfs3_proc_write() but the result is the same. My system only have 128MB RAM so I think it is trival that kmap(0 will actually do anything. Looks like the write path code of nfs has change a bit which causes this not going to work. The reason why nfs_writepage_sync() can't be used is because the nfs_writepage_sync() assumes page_offset(page) equals to file offset but in a swap page this is not true. Please give some hints what is going on or which part of code I should look for. regards, David Chow