From mboxrd@z Thu Jan 1 00:00:00 1970 From: Valdis.Kletnieks@vt.edu Subject: Re: [PATCH 27/39] union-mount: In-kernel copyup routines Date: Mon, 03 May 2010 21:40:04 -0400 Message-ID: <30882.1272937204@localhost> References: <1272928358-20854-1-git-send-email-vaurora@redhat.com> <1272928358-20854-28-git-send-email-vaurora@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==_Exmh_1272937204_7027P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , Jan Blunck To: Valerie Aurora Return-path: Received: from lennier.cc.vt.edu ([198.82.162.213]:37267 "EHLO lennier.cc.vt.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751033Ab0EDBkw (ORCPT ); Mon, 3 May 2010 21:40:52 -0400 In-Reply-To: Your message of "Mon, 03 May 2010 16:12:26 PDT." <1272928358-20854-28-git-send-email-vaurora@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: --==_Exmh_1272937204_7027P Content-Type: text/plain; charset=us-ascii On Mon, 03 May 2010 16:12:26 PDT, Valerie Aurora said: > When a file on the read-only layer of a union mount is altered, it > must be copied up to the topmost read-write layer. This patch creates > union_copyup() and its supporting routines. > --- > fs/union.c | 244 +++++++++++++++++++++++++++++++++++++++++++++++ > +/** > + * union_copyup_data - Copy up len bytes of old's data to new > + * > + * @old: source file > + * @new: target file > + * @len: number of bytes to copy > + */ > + > +static int union_copyup_data(struct path *old, struct vfsmount *new_mnt, > + struct dentry *new_dentry, size_t len) > +{ > + struct file *old_file; > + struct file *new_file; > + const struct cred *cred = current_cred(); > + loff_t offset = 0; > + long bytes; > + int error; Should this be 'int error = 0;' ? > + > + if (len == 0) > + return 0; > + > + /* Get reference to balance later fput() */ > + path_get(old); > + old_file = dentry_open(old->dentry, old->mnt, O_RDONLY, cred); > + if (IS_ERR(old_file)) > + return PTR_ERR(old_file); > + > + dget(new_dentry); > + mntget(new_mnt); > + new_file = dentry_open(new_dentry, new_mnt, O_WRONLY, cred); > + if (IS_ERR(new_file)) { > + error = PTR_ERR(new_file); > + goto out_fput; > + } > + > + bytes = do_splice_direct(old_file, &offset, new_file, len, > + SPLICE_F_MOVE); > + if (bytes < 0) > + error = bytes; > + > + fput(new_file); > +out_fput: > + fput(old_file); > + return error; > +} because otherwise if do_splice_direct() returns a non-negative value, we can hit 'return error;' without ever having set error to anything? --==_Exmh_1272937204_7027P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Exmh version 2.5 07/13/2001 iD8DBQFL33r0cC3lWbTT17ARAiArAJ4v7ikspt2rATmc/R0QfacxWz3XBgCgkh4j NuoEjs6tTGcc1+wHN6xU2/w= =Iv4e -----END PGP SIGNATURE----- --==_Exmh_1272937204_7027P--