From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 2/3] xfs: better xfs_trans_alloc interface
Date: Wed, 17 Feb 2016 08:40:08 -0500 [thread overview]
Message-ID: <20160217134006.GA4065@bfoster.bfoster> (raw)
In-Reply-To: <1455699159-20906-2-git-send-email-hch@lst.de>
On Wed, Feb 17, 2016 at 09:52:38AM +0100, Christoph Hellwig wrote:
> Merge xfs_trans_reserve and xfs_trans_alloc into a single function call
> that returns a transaction with all the required log and block reservations,
> and which allows passing transaction flags directly to avoid the cumbersome
> _xfs_trans_alloc interface.
>
> While we're at it we also get rid of the transaction type argument that has
> been superflous since we stopped supporting the non-CIL logging mode. The
> guts of it will be removed in another patch.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
Looks like a nice cleanup to me. A couple comments...
> fs/xfs/libxfs/xfs_attr.c | 58 +++++++-----------------------
> fs/xfs/libxfs/xfs_bmap.c | 22 +++++-------
> fs/xfs/libxfs/xfs_sb.c | 8 ++---
> fs/xfs/libxfs/xfs_shared.h | 5 +--
> fs/xfs/xfs_aops.c | 19 ++++------
> fs/xfs/xfs_attr_inactive.c | 16 ++-------
> fs/xfs/xfs_bmap_util.c | 45 +++++++-----------------
> fs/xfs/xfs_dquot.c | 7 ++--
> fs/xfs/xfs_file.c | 8 ++---
> fs/xfs/xfs_fsops.c | 10 ++----
> fs/xfs/xfs_inode.c | 60 ++++++++++++-------------------
> fs/xfs/xfs_ioctl.c | 13 +++----
> fs/xfs/xfs_iomap.c | 53 +++++++++-------------------
> fs/xfs/xfs_iops.c | 22 +++++-------
> fs/xfs/xfs_log_recover.c | 10 +++---
> fs/xfs/xfs_pnfs.c | 7 ++--
> fs/xfs/xfs_qm.c | 9 ++---
> fs/xfs/xfs_qm_syscalls.c | 26 ++++----------
> fs/xfs/xfs_rtalloc.c | 21 +++++------
> fs/xfs/xfs_symlink.c | 16 ++++-----
> fs/xfs/xfs_trans.c | 88 +++++++++++++++++++++-------------------------
> fs/xfs/xfs_trans.h | 8 ++---
> 22 files changed, 188 insertions(+), 343 deletions(-)
>
...
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 0d38b1d..3d9b1c48 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -599,10 +599,9 @@ xfs_setattr_nonsize(
> return error;
> }
>
> - tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
> - error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
> + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp);
> if (error)
> - goto out_trans_cancel;
> + goto out_dqrele;
>
> xfs_ilock(ip, XFS_ILOCK_EXCL);
>
> @@ -724,8 +723,7 @@ xfs_setattr_nonsize(
>
> out_unlock:
> xfs_iunlock(ip, XFS_ILOCK_EXCL);
> -out_trans_cancel:
> - xfs_trans_cancel(tp);
This causes a transaction leak in the event of
xfs_qm_vop_chown_reserve() failure (called earlier in the function,
after transaction allocation).
> +out_dqrele:
> xfs_qm_dqrele(udqp);
> xfs_qm_dqrele(gdqp);
> return error;
...
> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> index 748b16a..cbbef3a 100644
> --- a/fs/xfs/xfs_trans.c
> +++ b/fs/xfs/xfs_trans.c
...
> @@ -165,7 +123,7 @@ xfs_trans_dup(
> * This does not do quota reservations. That typically is done by the
> * caller afterwards.
> */
> -int
> +static int
> xfs_trans_reserve(
> struct xfs_trans *tp,
> struct xfs_trans_res *resp,
> @@ -219,7 +177,7 @@ xfs_trans_reserve(
> resp->tr_logres,
> resp->tr_logcount,
> &tp->t_ticket, XFS_TRANSACTION,
> - permanent, tp->t_type);
> + permanent, 0);
So this looks like it effectively breaks xlog_print_tic_res()..? I see
that is all removed in the subsequent patch, but the type still seems
like useful information in the event that an associated problem occurs
with the transaction. In fact, we just had a transaction overrun report
over the weekend (on irc) where at least I thought this was useful
(unfortunately it looks like I lost the reference to the syslog output).
Brian
> }
>
> if (error)
> @@ -268,6 +226,42 @@ undo_blocks:
> return error;
> }
>
> +int
> +xfs_trans_alloc(
> + struct xfs_mount *mp,
> + struct xfs_trans_res *resp,
> + uint blocks,
> + uint rtextents,
> + uint flags,
> + struct xfs_trans **tpp)
> +{
> + struct xfs_trans *tp;
> + int error;
> +
> + if (!(flags & XFS_TRANS_NO_WRITECOUNT))
> + sb_start_intwrite(mp->m_super);
> +
> + WARN_ON(mp->m_super->s_writers.frozen == SB_FREEZE_COMPLETE);
> + atomic_inc(&mp->m_active_trans);
> +
> + tp = kmem_zone_zalloc(xfs_trans_zone,
> + (flags & XFS_TRANS_NOFS) ? KM_NOFS : KM_SLEEP);
> + tp->t_magic = XFS_TRANS_HEADER_MAGIC;
> + tp->t_flags = flags;
> + tp->t_mountp = mp;
> + INIT_LIST_HEAD(&tp->t_items);
> + INIT_LIST_HEAD(&tp->t_busy);
> +
> + error = xfs_trans_reserve(tp, resp, blocks, rtextents);
> + if (error) {
> + xfs_trans_cancel(tp);
> + return error;
> + }
> +
> + *tpp = tp;
> + return 0;
> +}
> +
> /*
> * Record the indicated change to the given field for application
> * to the file system's superblock when the transaction commits.
> diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
> index e7c49cf..9a462e8 100644
> --- a/fs/xfs/xfs_trans.h
> +++ b/fs/xfs/xfs_trans.h
> @@ -90,7 +90,6 @@ void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
> */
> typedef struct xfs_trans {
> unsigned int t_magic; /* magic number */
> - unsigned int t_type; /* transaction type */
> unsigned int t_log_res; /* amt of log space resvd */
> unsigned int t_log_count; /* count for perm log res */
> unsigned int t_blk_res; /* # of blocks resvd */
> @@ -148,10 +147,9 @@ typedef struct xfs_trans {
> /*
> * XFS transaction mechanism exported interfaces.
> */
> -xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint);
> -xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint, xfs_km_flags_t);
> -int xfs_trans_reserve(struct xfs_trans *, struct xfs_trans_res *,
> - uint, uint);
> +int xfs_trans_alloc(struct xfs_mount *mp, struct xfs_trans_res *resp,
> + uint blocks, uint rtextents, uint flags,
> + struct xfs_trans **tpp);
> void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
>
> struct xfs_buf *xfs_trans_get_buf_map(struct xfs_trans *tp,
> --
> 2.1.4
>
> _______________________________________________
> 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
next prev parent reply other threads:[~2016-02-17 13:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 8:52 [PATCH 1/3] xfs: remove xfs_trans_get_block_res Christoph Hellwig
2016-02-17 8:52 ` [PATCH 2/3] xfs: better xfs_trans_alloc interface Christoph Hellwig
2016-02-17 13:40 ` Brian Foster [this message]
2016-02-17 22:04 ` Dave Chinner
2016-02-18 12:10 ` Brian Foster
2016-02-22 13:39 ` Christoph Hellwig
2016-02-22 21:14 ` Dave Chinner
2016-02-17 8:52 ` [PATCH 3/3] xfs: remove transaction types Christoph Hellwig
2016-02-17 8:57 ` [PATCH 1/3] xfs: remove xfs_trans_get_block_res Christoph Hellwig
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=20160217134006.GA4065@bfoster.bfoster \
--to=bfoster@redhat.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