Project

General

Profile

Bug #1898

Kernel assertion in zfs_putpage() raised by rfs_write()

Added by Dan Kruchinin almost 8 years ago. Updated over 7 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
zfs - Zettabyte File System
Start date:
2011-12-18
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:

Description

NFSv2 server side write() implementation raises kernel assertion in zfs_putpage().

panic[cpu0]/thread=ffffff017063dc40: assertion failed: len == 0, file: ../../common/fs/zfs/zfs_vnops.c, line: 4200

ffffff0005d6b1a0 genunix:assfail+7e ()
ffffff0005d6b260 zfs:zfs_putpage+373 ()
ffffff0005d6b2d0 genunix:fop_putpage+74 ()
ffffff0005d6b740 nfssrv:rfs_write+9bb ()
ffffff0005d6ba40 nfssrv:common_dispatch+4db ()
ffffff0005d6ba60 nfssrv:rfs_dispatch+2d ()
ffffff0005d6bb50 rpcmod:svc_getreq+20d ()
ffffff0005d6bbc0 rpcmod:svc_run+19a ()
ffffff0005d6bbf0 rpcmod:svc_do_run+81 ()
ffffff0005d6beb0 nfs:nfssys+77b ()
ffffff0005d6bf00 unix:brand_sys_sysenter+2b7 ()

How to reproduce

  1. Create an NFS share on ZFS filesystem
  2. Mount a share on another host (mount -F nfs -o vers=2 <other options> <target-dir>)
  3. echo "123" > <target-dir>/newfile

Possible root of the problem

NFSv2 rfs_write() method calculates the total length of the data it's going to write to the file. If the data is written successfully, it calls
VOP_PUTPAGE() method on the parent filesystem and passes total number of bytes written as a length argument. ZFS implementation of putpage method (zfs_putpage()) raises assertion if target vnode hasn't any cached data and at the same time length argument is not zero:

    /*
     * There's nothing to do if no data is cached.
     */
    if (!vn_has_cached_data(vp)) {
        ASSERT(len == 0);
        ZFS_EXIT(zfsvfs);
        return (0);
    }

According to the source code of zfs_vnops.c, zfs_write() doesn't touch a page cache, actually it doesn't use default page cache implementation in Illumos, rather it has sort of its own cache (that doesn't have anything in common with default one) implementation (as a part of DMU). ZFS updates page cache iff a vnode is memory mapped by some process.

Solution

It seems that cache operations in NFSv2 are closely related to UFS file system and I guess that the logic in rfs_write() is correct (at least for UFS). Assertion in zfs_write() seems to be odd, because ZFS is not the only filesystem in Illumos and probably we shouldn't forget about legacy FSes and interfaces.

I attached the patch that fixes the problem.


Files

zfs-putpage.patch (391 Bytes) zfs-putpage.patch Dan Kruchinin, 2011-12-18 06:52 PM

History

#1

Updated by Dan Kruchinin over 7 years ago

  • % Done changed from 0 to 100
#2

Updated by Rich Lowe over 7 years ago

  • Status changed from New to Resolved
  • Tags deleted (needs-triage)

Resolved in r13554:fae070bfb73a

Also available in: Atom PDF