public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 3/8] xfs: make the log ticket transaction id random
Date: Thu,  1 Apr 2010 23:41:26 +1100	[thread overview]
Message-ID: <1270125691-29266-4-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1270125691-29266-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

The transaction ID that is written to the log for a transaction is
currently set by taking the lower 32 bits of the memory address of
the ticket structure.  This is not guaranteed to be unique as
tickets comes from a slab and slots can be reallocated immediately
after being freed. As a result, there is no guarantee of uniqueness
in the ticket ID value.

Fix this by assigning a random number to the ticket ID field so that
it is extremely unlikely that duplicates will occur and remove the
possibility of transactions being mixed up during recovery due to
duplicate IDs.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_log.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 9edbd67..77593c2 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -3417,7 +3417,7 @@ xlog_ticket_alloc(
 	tic->t_curr_res		= unit_bytes;
 	tic->t_cnt		= cnt;
 	tic->t_ocnt		= cnt;
-	tic->t_tid		= (xlog_tid_t)((__psint_t)tic & 0xffffffff);
+	tic->t_tid		= random32();
 	tic->t_clientid		= client;
 	tic->t_flags		= XLOG_TIC_INITED;
 	tic->t_trans_type	= 0;
-- 
1.6.5

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

  parent reply	other threads:[~2010-04-01 12:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-01 12:41 [PATCH 0/8] xfs: bug fixes, cleanups and tracing Dave Chinner
2010-04-01 12:41 ` [PATCH 2/8] xfs: don't warn on EAGAIN in inode reclaim Dave Chinner
2010-04-03  9:25   ` Christoph Hellwig
2010-04-01 12:41 ` Dave Chinner [this message]
2010-04-03  9:31   ` [PATCH 3/8] xfs: make the log ticket transaction id random Christoph Hellwig
2010-04-05 23:39     ` Dave Chinner
2010-04-13 18:12       ` Christoph Hellwig
2010-04-01 12:41 ` [PATCH 4/8] xfs: add log item recovery tracing Dave Chinner
2010-04-03  9:36   ` Christoph Hellwig
2010-04-05 23:40     ` Dave Chinner
2010-04-01 12:41 ` [PATCH 5/8] xfs: convert the per-mount dquot list to use list heads Dave Chinner
2010-04-03  9:59   ` Christoph Hellwig
2010-04-01 12:41 ` [PATCH 6/8] xfs: remove duplicate code from dquot reclaim Dave Chinner
2010-04-03 10:00   ` Christoph Hellwig
2010-04-01 12:41 ` [PATCH 7/8] xfs: convert the dquot hash list to use list heads Dave Chinner
2010-04-03 10:00   ` Christoph Hellwig
2010-04-01 12:41 ` [PATCH 8/8] xfs: convert the dquot free " Dave Chinner
2010-04-03 10:00   ` Christoph Hellwig
2010-04-03 10:02 ` [PATCH 9/8] xfs: remove xfs_dqmarker Christoph Hellwig
2010-04-05 23:20   ` 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=1270125691-29266-4-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --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