Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jan 2012 00:26:49 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r230180 - head/sys/fs/tmpfs
Message-ID:  <201201160026.q0G0QnKf007380@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Mon Jan 16 00:26:49 2012
New Revision: 230180
URL: http://svn.freebsd.org/changeset/base/230180

Log:
  When tmpfs_write() resets an extended file to its original size after an
  error, we want tmpfs_reg_resize() to ignore I/O errors and unconditionally
  update the file's size.
  
  Reviewed by:	kib
  MFC after:	3 weeks

Modified:
  head/sys/fs/tmpfs/tmpfs.h
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs.h
==============================================================================
--- head/sys/fs/tmpfs/tmpfs.h	Sun Jan 15 23:00:33 2012	(r230179)
+++ head/sys/fs/tmpfs/tmpfs.h	Mon Jan 16 00:26:49 2012	(r230180)
@@ -436,7 +436,7 @@ struct tmpfs_dirent *	tmpfs_dir_lookupby
 int	tmpfs_dir_getdents(struct tmpfs_node *, struct uio *, off_t *);
 int	tmpfs_dir_whiteout_add(struct vnode *, struct componentname *);
 void	tmpfs_dir_whiteout_remove(struct vnode *, struct componentname *);
-int	tmpfs_reg_resize(struct vnode *, off_t);
+int	tmpfs_reg_resize(struct vnode *, off_t, boolean_t);
 int	tmpfs_chflags(struct vnode *, int, struct ucred *, struct thread *);
 int	tmpfs_chmod(struct vnode *, mode_t, struct ucred *, struct thread *);
 int	tmpfs_chown(struct vnode *, uid_t, gid_t, struct ucred *,

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_subr.c	Sun Jan 15 23:00:33 2012	(r230179)
+++ head/sys/fs/tmpfs/tmpfs_subr.c	Mon Jan 16 00:26:49 2012	(r230180)
@@ -882,7 +882,7 @@ tmpfs_dir_whiteout_remove(struct vnode *
  * Returns zero on success or an appropriate error code on failure.
  */
 int
-tmpfs_reg_resize(struct vnode *vp, off_t newsize)
+tmpfs_reg_resize(struct vnode *vp, off_t newsize, boolean_t ignerr)
 {
 	struct tmpfs_mount *tmp;
 	struct tmpfs_node *node;
@@ -952,8 +952,12 @@ retry:
 				} else {
 					vm_page_free(m);
 					vm_page_unlock(m);
-					VM_OBJECT_UNLOCK(uobj);
-					return (EIO);
+					if (ignerr)
+						m = NULL;
+					else {
+						VM_OBJECT_UNLOCK(uobj);
+						return (EIO);
+					}
 				}
 			}
 			if (m != NULL) {
@@ -1351,7 +1355,7 @@ tmpfs_truncate(struct vnode *vp, off_t l
 	if (length > VFS_TO_TMPFS(vp->v_mount)->tm_maxfilesize)
 		return (EFBIG);
 
-	error = tmpfs_reg_resize(vp, length);
+	error = tmpfs_reg_resize(vp, length, FALSE);
 	if (error == 0) {
 		node->tn_status |= TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED;
 	}

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vnops.c	Sun Jan 15 23:00:33 2012	(r230179)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c	Mon Jan 16 00:26:49 2012	(r230180)
@@ -747,7 +747,8 @@ tmpfs_write(struct vop_write_args *v)
 
 	extended = uio->uio_offset + uio->uio_resid > node->tn_size;
 	if (extended) {
-		error = tmpfs_reg_resize(vp, uio->uio_offset + uio->uio_resid);
+		error = tmpfs_reg_resize(vp, uio->uio_offset + uio->uio_resid,
+		    FALSE);
 		if (error != 0)
 			goto out;
 	}
@@ -773,7 +774,7 @@ tmpfs_write(struct vop_write_args *v)
 	}
 
 	if (error != 0)
-		(void)tmpfs_reg_resize(vp, oldsize);
+		(void)tmpfs_reg_resize(vp, oldsize, TRUE);
 
 out:
 	MPASS(IMPLIES(error == 0, uio->uio_resid == 0));



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