Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Jan 2011 19:23:43 +0000 (UTC)
From:      Martin Matuska <mm@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r216927 - stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201101031923.p03JNhNZ002826@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mm
Date: Mon Jan  3 19:23:43 2011
New Revision: 216927
URL: http://svn.freebsd.org/changeset/base/216927

Log:
  MFC r207745 (trasz):
  
  Enforce RLIMIT_FSIZE in ZFS.
  
  Note: original implementation without vn_rlimit_fsize (pre-r207662)
  
  Reviewed by:	trasz
  Approved by:	pjd

Modified:
  stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==============================================================================
--- stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Mon Jan  3 18:34:28 2011	(r216926)
+++ stable/8/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c	Mon Jan  3 19:23:43 2011	(r216927)
@@ -30,6 +30,7 @@
 #include <sys/systm.h>
 #include <sys/sysmacros.h>
 #include <sys/resource.h>
+#include <sys/resourcevar.h>
 #include <sys/vfs.h>
 #include <sys/vnode.h>
 #include <sys/file.h>
@@ -4362,6 +4363,17 @@ zfs_freebsd_write(ap)
 	} */ *ap;
 {
 
+	if (ap->a_vp->v_type == VREG && ap->a_uio->uio_td != NULL) {
+		PROC_LOCK(ap->a_uio->uio_td->td_proc);
+		if (ap->a_uio->uio_offset + ap->a_uio->uio_resid >
+		    lim_cur(ap->a_uio->uio_td->td_proc, RLIMIT_FSIZE)) {
+			psignal(ap->a_uio->uio_td->td_proc, SIGXFSZ);
+			PROC_UNLOCK(ap->a_uio->uio_td->td_proc);
+			return (EFBIG);
+		}
+		PROC_UNLOCK(ap->a_uio->uio_td->td_proc);
+	}
+
 	return (zfs_write(ap->a_vp, ap->a_uio, ioflags(ap->a_ioflag),
 	    ap->a_cred, NULL));
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101031923.p03JNhNZ002826>