public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Chinner <dgc@sgi.com>
To: Christoph Hellwig <hch@lst.de>
Cc: xfs@oss.sgi.com
Subject: Re: odd code in xfs_remove
Date: Fri, 11 Apr 2008 12:31:45 +1000	[thread overview]
Message-ID: <20080411023145.GK103491721@sgi.com> (raw)
In-Reply-To: <20080410185445.GA7521@lst.de>

On Thu, Apr 10, 2008 at 08:54:45PM +0200, Christoph Hellwig wrote:
> unlike xfs_rmdir or xfs_rename xfs_remove always passes 0 instead of the
> reserved blocks to xfs_dir_removename which means the latter always
> operated in the ENOSPC mode.  This seems rather strange to me, so a
> second pair of eyes, especially on a tree with history back to day 0
> would be nice.

Originially, back in the days of dir1 (1994) when xfs_dir_removename()
was expanded to take a block count, only xfs_rename() passed a value
in (MAX_EXT_NEEDED). Both xfs_rmdir and xfs_remove passed zero.

Then some time later (pv 519072):

irix/kern/fs/xfs/xfs_vnodeops.c - 1.356
        - Add more vnode tracing points.  Remove some cruft from merge errors.
          Speed up xfs_remove by getting a real space reservation unless the fs
          is full, then reverting to a zero space reservation (bug 519072). 

The speed up was for dir v1, which doesn't exist on linux. Then in pv 653987:

irix/kern/fs/xfs/xfs_vnodeops.c - 1.395
        - In xfs_link, call xfs_dir_canenter before xfs_dir_createname if we
          have no space reservation.
          In xfs_rmdir, get a 0 space reservation if we can't get the real space
          reservation (as is done for xfs_remove).
          In xfs_symlink, properly account for resblks throughout so we don't 
          make it go negative to a xfs_bmapi call.

The key point here is that in rev 1.395, the variable resblks got passed
into xfs_dir_removename(), whilst in 1.356, it didn't. This was work
that preceeded dir v2, so was probably fixing bugs found as a result.

The remove name case with resblks = 0 avoids block allocation during
modification of the alloc btree to insert newly freed blocks at
ENOSPC; instead it just leaves the empty leaf block in place in the
directory.

Looks like no harm is done by this and it's a rarely hit corner
case, but it would appear that we should be passing in resblks in
remove if only to avoid a potential transaction reservation
overrun....

Cheers,

Dave.
-- 
Dave Chinner
Principal Engineer
SGI Australian Software Group

  reply	other threads:[~2008-04-11  2:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-10 18:54 odd code in xfs_remove Christoph Hellwig
2008-04-11  2:31 ` David Chinner [this message]
2008-04-11  7:40   ` 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=20080411023145.GK103491721@sgi.com \
    --to=dgc@sgi.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