From owner-freebsd-fs@FreeBSD.ORG Sat May 19 20:22:28 2012 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CFDAC106564A; Sat, 19 May 2012 20:22:28 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx1.freebsd.org (Postfix) with ESMTP id EB7FF8FC14; Sat, 19 May 2012 20:22:26 +0000 (UTC) Received: by wibhj8 with SMTP id hj8so958602wib.13 for ; Sat, 19 May 2012 13:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=CUEjzUeoM6vkublWMFBHavyot1A+2oDenbP53gZHlBU=; b=WlaPxvmzbmIppTwGpJnzIGlA8zFi3zKCVW5chP5nMAwZ/ltFinRwIhJHoDjMHiFqzh H4IasA46DDdBahqE9hR6wmKlHtRtq2xo5AOl68AP6HZf7pYd8Lb5fiFjspX/nmsIFt3V 9LpGFOzT+fmHampyd1wV4LdNZ+AHezsetdLt9AygJdahbSGMdxW4wWnVOzd5003WW6TD 2qeVB4BBGrIrmWYa3hQ5b5xv4hL1EDSVfvXVpGGy4u7MXb5W9xrLXpUY8dqBVP7+eC2G UeYaY9z1/WxMYP21AXA5GL/p78GNhcdJtdlPszwihOuV/ewabJSmIJu9C8uP6LqLmjUw PNgg== Received: by 10.180.109.229 with SMTP id hv5mr22753555wib.0.1337458945528; Sat, 19 May 2012 13:22:25 -0700 (PDT) Received: from dft-labs.eu (dft-labs.eu. [80.87.128.179]) by mx.google.com with ESMTPS id f19sm18657520wiw.11.2012.05.19.13.22.23 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 19 May 2012 13:22:24 -0700 (PDT) Date: Sat, 19 May 2012 22:22:13 +0200 From: Mateusz Guzik To: pjd@freebsd.org Message-ID: <20120519202213.GA17691@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-fs@freebsd.org Subject: [patch] Broken RLIMIT_FSIZE handling in ZFS X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 May 2012 20:22:28 -0000 Hello, vn_rlimit_fsize takes uio->uio_offset and uio->uio_resid into account when determining whether given write would exceed RLIMIT_FSIZE. When APPEND flag is specified, ZFS updates uio->uio_offset to point to the end of file. But this happens after a call to vn_rlimit_fsize, so vn_rlimit_fsize check can be rendered ineffective by thread that opens some file with O_APPEND and lseeks below RLIMIT_FSIZE before calling write. This fixes the problem for me: http://student.agh.edu.pl/~mjguzik/patches/zfs-rlimit-fsize.patch Slightly modified testcase stolen from pr standards/164793: http://student.agh.edu.pl/~mjguzik/patches/writelimit.c Without the patch this testacase will just finish by producing 80000 bytes file on ZFS. On UFS it gives the following output: failed when adding 27 bytes after 59994 bytes (error: File too large) Same happens on ZFS with the patch. -- Mateusz Guzik