All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dave@jikos.cz>
To: "Fajar A. Nugraha" <list@fajar.net>
Cc: dave@jikos.cz, "Hugo Mills" <hugo@carfax.org.uk>,
	"Swâmi Petaramesh" <swami@petaramesh.org>,
	linux-btrfs@vger.kernel.org
Subject: Re: BTRFS fsck apparent errors
Date: Thu, 5 Jul 2012 02:32:02 +0200	[thread overview]
Message-ID: <20120705003202.GQ5326@twin.jikos.cz> (raw)
In-Reply-To: <CAG1y0sda5EqfVp0rP7eJpTdvFFOfWv2DidJPRDDKkrycHvdJiQ@mail.gmail.com>

On Wed, Jul 04, 2012 at 10:46:21PM +0700, Fajar A. Nugraha wrote:
> > Is it just mount/umount without any other activity?
> Yes
> 
> > Is the fs
> > fragmented
> Not sure how to check that quickly
> 
> > (or aged),
> Over 1 year, so yes
> 
> > almost full,
> df says 83% used, so probably yes (depending on how you define "almost")

that matches my expectation that could lead to the mount/umount
slowness due to fragmentation

> > has lots of files?
> 
> it's a "normal" 1 TB usb disk, with docs, movies, vm images, etc. No
> particular lots-of-small-files like maildir or anything like that.

So it's probably not an issue with inode_cache.

> >> # time umount /media/WD-root/
> >>
> >> real  0m22.419s
> >> user  0m0.000s
> >> sys   0m0.064s
> >>
> >> # /proc/10142/stack  <--- the PID of umount process
> >
> > The process(es) actually doing the work are the btrfs workers, usual
> > sucspects are btrfs-cache (free space cache) or btrfs-ino (inode cache)
> > that are writing the cache states back to disk.
> 
> Not sure about that, since iostat shows it's mostly read, not write.
> Will try iotop later.
> I tested also with Chris' for-linus on top of 3.4, same result (really
> long time to umount).

Would be good to verify if it's the btrfs-cache worker or not, IIRC
there were more writes than reads, so I'm not sure this is the right
direction.

The 3.5 series or 3.4+for-linus has some changes wrt free space cache
(removed the 'ideal caching mode') that caused slow mounts but has been
fixed.

I've looked again at the umount process call stack, and it's waiting
for writing the btree_inode which is the representation of the b-tree
nodes, it's quite possible that changes to the generic writeback code is
causing this. AFAIK the btree_inode does not behave as a normal file
inode regarding writeback.  The good reference point is 3.2, there were
non-trivial writeback changes merged since.

Guessing now, if the mount causes eg. atime update, then this triggers
cow, dirties the btree_inode and needs to read data from disk,
fragmentation slows this down. Number of cowed blocks is small compared
to the reads (and maybe generic readahead reads more than what's
actually needed for the cow operation ...).


david

      reply	other threads:[~2012-07-05  0:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-03 15:10 BTRFS fsck apparent errors Swâmi Petaramesh
2012-07-03 15:22 ` Hugo Mills
2012-07-03 15:52   ` David Sterba
2012-07-03 16:26     ` Zach Brown
2012-07-03 17:37       ` David Sterba
2012-07-03 17:42         ` Zach Brown
2012-07-04  3:25         ` Dave Chinner
2012-07-03 19:17   ` Swâmi Petaramesh
2012-07-04  0:40   ` Fajar A. Nugraha
2012-07-04 13:42     ` David Sterba
2012-07-04 15:46       ` Fajar A. Nugraha
2012-07-05  0:32         ` David Sterba [this message]

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=20120705003202.GQ5326@twin.jikos.cz \
    --to=dave@jikos.cz \
    --cc=hugo@carfax.org.uk \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=list@fajar.net \
    --cc=swami@petaramesh.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.