public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <Anand.Jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH RFC] btrfs: total_devices vs num_devices
Date: Wed, 26 Feb 2014 15:22:45 +0800	[thread overview]
Message-ID: <1393399365-8393-1-git-send-email-Anand.Jain@oracle.com> (raw)

The intended usage of total_devices and num_devices
should be recorded in the comments so that these
two counters can be used correctly to match the
original intentions.

And there appears to be bugs due to missing clarity,
the bugs are mainly in the fact that in the current
code the num_devices does not count seed devices where
as total_devices does, next, total_devices does not count
the replacing devices where as num_devices does.

In this situation the ioctl(BTRFS_IOC_DEVICES_READY)
will fails when there is seed FS.
The applications using ioctl(BTRFS_IOC_FS_INFO) and
ioctl(BTRFS_IOC_DEV_INFO) in conjuction to allocate
the slots will also be confused as farmer depend on
the num_devices where as later would match total_devices
(except when replace is running).

This patch will help have the clarity on usage
of these two counter so that bugs related to this can
be fixed.

Signed-off-by: Anand Jain <Anand.Jain@oracle.com>
---
 fs/btrfs/volumes.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 91b7596..99c71aa 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -121,12 +121,18 @@ struct btrfs_fs_devices {
 	/* the device with this id has the most recent copy of the super */
 	u64 latest_devid;
 	u64 latest_trans;
+	/* num_devices contains run time count of devices which are part
+	 * of this FSID. (the FS devices + replacing devices + ?
+	 */
 	u64 num_devices;
 	u64 open_devices;
 	u64 rw_devices;
 	u64 missing_devices;
 	u64 total_rw_bytes;
 	u64 num_can_discard;
+	/* total_devices contains static recorded count of device which
+	 * are part of this FSID. (the FS devices + seed devices + ?
+	 */
 	u64 total_devices;
 	struct block_device *latest_bdev;
 
-- 
1.8.5.3


             reply	other threads:[~2014-02-26  7:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26  7:22 Anand Jain [this message]
2014-02-26  7:56 ` [PATCH RFC] btrfs: total_devices vs num_devices Anand Jain

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=1393399365-8393-1-git-send-email-Anand.Jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox