From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 4/5] xfs: simplify the fallocate path
Date: Mon, 10 Dec 2012 13:09:56 +1100 [thread overview]
Message-ID: <20121210020956.GN15784@dastard> (raw)
In-Reply-To: <20121208121006.286014845@bombadil.infradead.org>
On Sat, Dec 08, 2012 at 07:08:16AM -0500, Christoph Hellwig wrote:
> Call xfs_alloc_file_space or xfs_free_file_space directly from
> xfs_file_fallocate instead of going through xfs_change_file_space.
>
> This simplified the code by removing the unessecary marshalling of the
> arguments into an xfs_flock64_t structure and allows removing checks that
> are already done in the VFS code.
.....
> goto out_unlock;
> + setprealloc = true;
You don't use this flag anywhere ;)
> }
>
> - if (file->f_flags & O_DSYNC)
> - attr_flags |= XFS_ATTR_SYNC;
>
> - error = -xfs_change_file_space(ip, cmd, &bf, 0, attr_flags);
> + tp = xfs_trans_alloc(ip->i_mount, XFS_TRANS_WRITEID);
> + error = xfs_trans_reserve(tp, 0, XFS_WRITEID_LOG_RES(ip->i_mount),
> + 0, 0, 0);
> + if (error) {
> + xfs_trans_cancel(tp, 0);
> + goto out_unlock;
> + }
> +
> + xfs_ilock(ip, XFS_ILOCK_EXCL);
> + xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
> + ip->i_d.di_mode &= ~S_ISUID;
> + if (ip->i_d.di_mode & S_IXGRP)
> + ip->i_d.di_mode &= ~S_ISGID;
> +
> + if (!(mode & FALLOC_FL_PUNCH_HOLE))
> + ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC;
> +
> + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
> +
> + if (file->f_flags & O_DSYNC)
> + xfs_trans_set_sync(tp);
> + error = xfs_trans_commit(tp, 0);
While I like most of this series, I don't really like the
duplication of this piece of code. It seems to me that a simple
helper like:
int
xfs_inode_set_prealloc(
struct xfs_inode *ip,
bool set_prealloc,
bool clear_prealloc,
bool clear_sguid,
bool sync)
might be better, and call it from both the ioctl and fallocate
code...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-12-10 2:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-08 12:08 [PATCH 0/5] refactor the preallocation and hole punching code Christoph Hellwig
2012-12-08 12:08 ` [PATCH 1/5] xfs: remove the unused XFS_ATTR_NONBLOCK flag Christoph Hellwig
2012-12-08 12:08 ` [PATCH 2/5] xfs: always take the iolock around xfs_setattr_size Christoph Hellwig
2012-12-08 12:08 ` [PATCH 3/5] xfs: always hold the iolock when calling xfs_change_file_space Christoph Hellwig
2012-12-08 12:08 ` [PATCH 4/5] xfs: simplify the fallocate path Christoph Hellwig
2012-12-10 2:09 ` Dave Chinner [this message]
2012-12-10 10:52 ` Christoph Hellwig
2012-12-08 12:08 ` [PATCH 5/5] xfs: fold xfs_change_file_space into xfs_ioc_space Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2013-10-12 7:55 [PATCH 0/5] refactor the preallocation and hole punching code Christoph Hellwig
2013-10-12 7:55 ` [PATCH 4/5] xfs: simplify the fallocate path Christoph Hellwig
2013-10-14 5:04 ` Dave Chinner
2013-10-14 7:30 ` Christoph Hellwig
2013-10-14 20:03 ` Dave Chinner
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=20121210020956.GN15784@dastard \
--to=david@fromorbit.com \
--cc=hch@infradead.org \
--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