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 17/22] libxfs: update xfs_alloc to current kernel version
Date: Wed, 12 Jun 2013 20:36:29 +1000	[thread overview]
Message-ID: <1371033394-26006-18-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1371033394-26006-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 libxfs/xfs_alloc.c |   31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c
index 1d7ea8f..757b43d 100644
--- a/libxfs/xfs_alloc.c
+++ b/libxfs/xfs_alloc.c
@@ -153,6 +153,7 @@ xfs_alloc_compute_diff(
 	xfs_agblock_t	wantbno,	/* target starting block */
 	xfs_extlen_t	wantlen,	/* target length */
 	xfs_extlen_t	alignment,	/* target alignment */
+	char		userdata,	/* are we allocating data? */
 	xfs_agblock_t	freebno,	/* freespace's starting block */
 	xfs_extlen_t	freelen,	/* freespace's length */
 	xfs_agblock_t	*newbnop)	/* result: best start block from free */
@@ -167,7 +168,14 @@ xfs_alloc_compute_diff(
 	ASSERT(freelen >= wantlen);
 	freeend = freebno + freelen;
 	wantend = wantbno + wantlen;
-	if (freebno >= wantbno) {
+	/*
+	 * We want to allocate from the start of a free extent if it is past
+	 * the desired block or if we are allocating user data and the free
+	 * extent is before desired block. The second case is there to allow
+	 * for contiguous allocation from the remaining free space if the file
+	 * grows in the short term.
+	 */
+	if (freebno >= wantbno || (userdata && freeend < wantend)) {
 		if ((newbno1 = roundup(freebno, alignment)) >= freeend)
 			newbno1 = NULLAGBLOCK;
 	} else if (freeend >= wantend && alignment > 1) {
@@ -783,7 +791,8 @@ xfs_alloc_find_best_extent(
 			xfs_alloc_fix_len(args);
 
 			sdiff = xfs_alloc_compute_diff(args->agbno, args->len,
-						       args->alignment, *sbnoa,
+						       args->alignment,
+						       args->userdata, *sbnoa,
 						       *slena, &new);
 
 			/*
@@ -954,7 +963,8 @@ restart:
 			if (args->len < blen)
 				continue;
 			ltdiff = xfs_alloc_compute_diff(args->agbno, args->len,
-				args->alignment, ltbnoa, ltlena, &ltnew);
+				args->alignment, args->userdata, ltbnoa,
+				ltlena, &ltnew);
 			if (ltnew != NULLAGBLOCK &&
 			    (args->len > blen || ltdiff < bdiff)) {
 				bdiff = ltdiff;
@@ -1106,7 +1116,8 @@ restart:
 			args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen);
 			xfs_alloc_fix_len(args);
 			ltdiff = xfs_alloc_compute_diff(args->agbno, args->len,
-				args->alignment, ltbnoa, ltlena, &ltnew);
+				args->alignment, args->userdata, ltbnoa,
+				ltlena, &ltnew);
 
 			error = xfs_alloc_find_best_extent(args,
 						&bno_cur_lt, &bno_cur_gt,
@@ -1122,7 +1133,8 @@ restart:
 			args->len = XFS_EXTLEN_MIN(gtlena, args->maxlen);
 			xfs_alloc_fix_len(args);
 			gtdiff = xfs_alloc_compute_diff(args->agbno, args->len,
-				args->alignment, gtbnoa, gtlena, &gtnew);
+				args->alignment, args->userdata, gtbnoa,
+				gtlena, &gtnew);
 
 			error = xfs_alloc_find_best_extent(args,
 						&bno_cur_gt, &bno_cur_lt,
@@ -1181,7 +1193,7 @@ restart:
 	}
 	rlen = args->len;
 	(void)xfs_alloc_compute_diff(args->agbno, rlen, args->alignment,
-				     ltbnoa, ltlena, &ltnew);
+				     args->userdata, ltbnoa, ltlena, &ltnew);
 	ASSERT(ltnew >= ltbno);
 	ASSERT(ltnew + rlen <= ltbnoa + ltlena);
 	ASSERT(ltnew + rlen <= be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
@@ -2173,13 +2185,8 @@ xfs_agf_verify(
 	struct xfs_agf	*agf = XFS_BUF_TO_AGF(bp);
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	    !uuid_equal(&agf->agf_uuid, &mp->m_sb.sb_uuid)) {
-		char uu[64], uu2[64];
-		platform_uuid_unparse(&agf->agf_uuid, uu);
-		platform_uuid_unparse(&mp->m_sb.sb_uuid, uu2);
-
+	    !uuid_equal(&agf->agf_uuid, &mp->m_sb.sb_uuid))
 			return false;
-	}
 
 	if (!(agf->agf_magicnum == cpu_to_be32(XFS_AGF_MAGIC) &&
 	      XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) &&
-- 
1.7.10.4

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

  parent reply	other threads:[~2013-06-12 10:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-12 10:36 [PATCH 00/22] xfsprogs: sync up with 3.11 kernel code Dave Chinner
2013-06-12 10:36 ` [PATCH 01/22] xfsprogs: introduce xfs_icreate.h Dave Chinner
2013-06-12 10:36 ` [PATCH 02/22] xfsprogs: port inode create transaction changes Dave Chinner
2013-06-12 10:36 ` [PATCH 03/22] xfsprogs: teach logprint about icreate transaction Dave Chinner
2013-06-12 10:36 ` [PATCH 04/22] libxfs: switch over to xfs_sb.c and remove xfs_mount.c Dave Chinner
2013-06-12 10:36 ` [PATCH 05/22] libxfs: move the transaction reservation structures Dave Chinner
2013-06-12 10:36 ` [PATCH 06/22] xfsprogs: remove xfs_mount.h Dave Chinner
2013-06-12 10:36 ` [PATCH 07/22] libxfs: update xfs_inode.h to match new kernel version Dave Chinner
2013-06-12 10:36 ` [PATCH 08/22] xfs: remove local fork format handling from xfs_bmapi_write() Dave Chinner
2013-06-12 10:36 ` [PATCH 09/22] libxfs: local to remote format support of remote symlinks Dave Chinner
2013-06-12 10:36 ` [PATCH 10/22] xfsprogs: sync minor kernel header differences Dave Chinner
2013-06-12 10:36 ` [PATCH 11/22] libxfs: introduce xfs_trans_resv.c Dave Chinner
2013-06-12 10:36 ` [PATCH 12/22] libxfs: fix directory/attribute format issues Dave Chinner
2013-06-12 10:36 ` [PATCH 13/22] libxfs: ensure btree root split sets blkno correctly Dave Chinner
2013-06-12 10:36 ` [PATCH 14/22] libxfs: move transaction code to trans.c Dave Chinner
2013-06-12 10:36 ` [PATCH 15/22] libxfs: fix byte swapping on constants Dave Chinner
2013-06-12 10:36 ` [PATCH 16/22] libxfs: sync xfs_da_btree.c Dave Chinner
2013-06-12 10:36 ` Dave Chinner [this message]
2013-06-12 10:36 ` [PATCH 18/22] libxfs: sync attr code with kernel Dave Chinner
2013-06-12 10:36 ` [PATCH 19/22] libxfs: sync dir2 kernel differences Dave Chinner
2013-06-12 10:36 ` [PATCH 20/22] libxfs: sync xfs_ialloc.c to the kernel code Dave Chinner
2013-06-12 10:36 ` [PATCH 21/22] xfsprogs: define min/max once and use them everywhere Dave Chinner
2013-06-12 10:36 ` [PATCH 22/22] libxfs: fix compile warnings 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=1371033394-26006-18-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