public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 1/3] xfs: pass inode instead of file to xfs_reflink_dirty_range
Date: Mon, 4 Jan 2016 17:23:09 -0800	[thread overview]
Message-ID: <20160105012309.GI28330@birch.djwong.org> (raw)
In-Reply-To: <1451822873-12969-2-git-send-email-hch@lst.de>

On Sun, Jan 03, 2016 at 01:07:51PM +0100, Christoph Hellwig wrote:
> We don't actually need a file for write_begin/end, those can be passed
> as NULL for disk based file systems.  This is important as we won't

I wasn't aware that one could /do/ that. :)

Looks good, though.  I think I can clean the filp arguments out of the reflink
code entirely, too.

--D

> even have a file pointer during a truncate operation, which gives a
> guaranteed NULL pointer dererference with the current code.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_reflink.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index da4a715..4a3f0ee 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -1316,7 +1316,7 @@ out_error:
>   */
>  STATIC int
>  xfs_reflink_dirty_range(
> -	struct file		*filp,
> +	struct inode		*inode,
>  	xfs_off_t		pos,
>  	xfs_off_t		len)
>  {
> @@ -1330,14 +1330,14 @@ xfs_reflink_dirty_range(
>  	unsigned long		bytes;	/* Bytes to write to page */
>  	void			*fsdata;
>  
> -	mapping = filp->f_mapping;
> +	mapping = inode->i_mapping;
>  	a_ops = mapping->a_ops;
>  	flags = AOP_FLAG_UNINTERRUPTIBLE;
>  	do {
>  
>  		offset = (pos & (PAGE_CACHE_SIZE - 1));
>  		bytes = min_t(unsigned long, len, PAGE_CACHE_SIZE) - offset;
> -		rpage = xfs_get_page(file_inode(filp), pos);
> +		rpage = xfs_get_page(inode, pos);
>  		if (IS_ERR(rpage)) {
>  			error = PTR_ERR(rpage);
>  			break;
> @@ -1346,24 +1346,24 @@ xfs_reflink_dirty_range(
>  			break;
>  		}
>  
> -		error = a_ops->write_begin(filp, mapping, pos, bytes, flags,
> +		error = a_ops->write_begin(NULL, mapping, pos, bytes, flags,
>  					   &page, &fsdata);
>  		page_cache_release(rpage);
>  		if (error < 0)
>  			break;
>  
> -		trace_xfs_reflink_unshare_page(file_inode(filp), page,
> +		trace_xfs_reflink_unshare_page(inode, page,
>  				pos, bytes);
>  
>  		if (!PageUptodate(page)) {
> -			pr_err("%s: STALE? ino=%lu pos=%llu\n",
> -				__func__, filp->f_inode->i_ino, pos);
> +			pr_err("%s: STALE? ino=%llu pos=%llu\n",
> +				__func__, XFS_I(inode)->i_ino, pos);
>  			WARN_ON(1);
>  		}
>  		if (mapping_writably_mapped(mapping))
>  			flush_dcache_page(page);
>  
> -		error = a_ops->write_end(filp, mapping, pos, bytes, bytes,
> +		error = a_ops->write_end(NULL, mapping, pos, bytes, bytes,
>  					 page, fsdata);
>  		if (error < 0)
>  			break;
> @@ -1454,7 +1454,7 @@ xfs_reflink_dirty_extents(
>  			flen = XFS_FSB_TO_B(mp, rlen);
>  			if (fpos + flen > isize)
>  				flen = isize - fpos;
> -			error = xfs_reflink_dirty_range(filp, fpos, flen);
> +			error = xfs_reflink_dirty_range(VFS_I(ip), fpos, flen);
>  			xfs_ilock(ip, XFS_ILOCK_EXCL);
>  			if (error)
>  				goto out;
> -- 
> 1.9.1
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2016-01-05  1:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-03 12:07 reflink fixes Christoph Hellwig
2016-01-03 12:07 ` [PATCH 1/3] xfs: pass inode instead of file to xfs_reflink_dirty_range Christoph Hellwig
2016-01-05  1:23   ` Darrick J. Wong [this message]
2016-01-03 12:07 ` [PATCH 2/3] xfs: only end a COW operation in xfs_zero_remaining_bytes if we started one Christoph Hellwig
2016-01-05  1:28   ` Darrick J. Wong
2016-01-03 12:07 ` [PATCH 3/3] xfs: cancel COW in xfs_cancel_ioend Christoph Hellwig
2016-01-05  1:43   ` Darrick J. Wong
2016-01-05 10:42     ` Christoph Hellwig
2016-01-07  0:32       ` Darrick J. Wong
2016-01-07 15:25         ` Christoph Hellwig
2016-01-08 10:09           ` Darrick J. Wong
2016-01-08 13:47             ` Christoph Hellwig
2016-01-09 21:17               ` Darrick J. Wong
2016-01-10  7:54                 ` Christoph Hellwig
2016-01-10 22:48     ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160105012309.GI28330@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox