linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Btrfs updates for 3.14-rc - sysfs, ioctl
@ 2014-02-07 13:33 David Sterba
  2014-02-07 13:33 ` [PATCH 1/4] btrfs: commit transaction after setting label and features David Sterba
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: David Sterba @ 2014-02-07 13:33 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Two minor fixes to the new sysfs code and a RFC change to replace the
GLOBAL_RSV ioctl with the same information exported through SPACE_INFO ioctl.

This requires to reserve a blockgroup type that will become part of ABI.

David Sterba (3):
  btrfs: reserve no transaction units in btrfs_ioctl_set_features
  btrfs: export global block reserve size as space_info
  Revert "btrfs: add ioctl to export size of global metadata
    reservation"

Jeff Mahoney (1):
  btrfs: commit transaction after setting label and features

 fs/btrfs/ctree.h           |  9 ++++++++-
 fs/btrfs/ioctl.c           | 42 +++++++++++++++++++++++-------------------
 include/uapi/linux/btrfs.h |  1 -
 3 files changed, 31 insertions(+), 21 deletions(-)

-- 
1.8.5.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/4] btrfs: commit transaction after setting label and features
  2014-02-07 13:33 [PATCH 0/4] Btrfs updates for 3.14-rc - sysfs, ioctl David Sterba
@ 2014-02-07 13:33 ` David Sterba
  2014-02-07 13:34 ` [PATCH 2/4] btrfs: reserve no transaction units in btrfs_ioctl_set_features David Sterba
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2014-02-07 13:33 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Jeff Mahoney, David Sterba

From: Jeff Mahoney <jeffm@suse.com>

The set_fslabel ioctl uses btrfs_end_transaction, which means it's
possible that the change will be lost if the system crashes, same for
the newly set features. Let's use btrfs_commit_transaction instead.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/ioctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index b0134892dc70..8e48b81e1515 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4525,7 +4525,7 @@ static int btrfs_ioctl_set_fslabel(struct file *file, void __user *arg)
 	spin_lock(&root->fs_info->super_lock);
 	strcpy(super_block->label, label);
 	spin_unlock(&root->fs_info->super_lock);
-	ret = btrfs_end_transaction(trans, root);
+	ret = btrfs_commit_transaction(trans, root);
 
 out_unlock:
 	mnt_drop_write_file(file);
@@ -4689,7 +4689,7 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
 	btrfs_set_super_incompat_flags(super_block, newflags);
 	spin_unlock(&root->fs_info->super_lock);
 
-	return btrfs_end_transaction(trans, root);
+	return btrfs_commit_transaction(trans, root);
 }
 
 long btrfs_ioctl(struct file *file, unsigned int
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] btrfs: reserve no transaction units in btrfs_ioctl_set_features
  2014-02-07 13:33 [PATCH 0/4] Btrfs updates for 3.14-rc - sysfs, ioctl David Sterba
  2014-02-07 13:33 ` [PATCH 1/4] btrfs: commit transaction after setting label and features David Sterba
@ 2014-02-07 13:34 ` David Sterba
  2014-02-07 13:34 ` [PATCH 3/4][RFC] btrfs: export global block reserve size as space_info David Sterba
  2014-02-07 13:34 ` [PATCH 4/4] Revert "btrfs: add ioctl to export size of global metadata reservation" David Sterba
  3 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2014-02-07 13:34 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Added in patch "btrfs: add ioctls to query/change feature bits online"
modifications to superblock don't need to reserve metadata blocks when
starting a transaction.

Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 8e48b81e1515..383ab455bfa7 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4668,7 +4668,7 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
 	if (ret)
 		return ret;
 
-	trans = btrfs_start_transaction(root, 1);
+	trans = btrfs_start_transaction(root, 0);
 	if (IS_ERR(trans))
 		return PTR_ERR(trans);
 
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4][RFC] btrfs: export global block reserve size as space_info
  2014-02-07 13:33 [PATCH 0/4] Btrfs updates for 3.14-rc - sysfs, ioctl David Sterba
  2014-02-07 13:33 ` [PATCH 1/4] btrfs: commit transaction after setting label and features David Sterba
  2014-02-07 13:34 ` [PATCH 2/4] btrfs: reserve no transaction units in btrfs_ioctl_set_features David Sterba
@ 2014-02-07 13:34 ` David Sterba
  2014-02-10 17:03   ` Chris Mason
  2014-02-07 13:34 ` [PATCH 4/4] Revert "btrfs: add ioctl to export size of global metadata reservation" David Sterba
  3 siblings, 1 reply; 7+ messages in thread
From: David Sterba @ 2014-02-07 13:34 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba, Jeff Mahoney, Josef Bacik

Introduce a block group type bit for a global reserve and fill the space
info for SPACE_INFO ioctl. This should replace the newly added ioctl
(01e219e8069516cdb98594d417b8bb8d906ed30d) to get just the 'size' part
of the global reserve, while the actual usage can be now visible in the
'btrfs fi df' output during ENOSPC stress.

The unpatched userspace tools will show the blockgroup as 'unknown'.

CC: Jeff Mahoney <jeffm@suse.com>
CC: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/ctree.h |  9 ++++++++-
 fs/btrfs/ioctl.c | 20 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 2c1a42ca519f..8bf1890ea21f 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -985,7 +985,8 @@ struct btrfs_dev_replace_item {
 #define BTRFS_BLOCK_GROUP_RAID10	(1ULL << 6)
 #define BTRFS_BLOCK_GROUP_RAID5         (1ULL << 7)
 #define BTRFS_BLOCK_GROUP_RAID6         (1ULL << 8)
-#define BTRFS_BLOCK_GROUP_RESERVED	BTRFS_AVAIL_ALLOC_BIT_SINGLE
+#define BTRFS_BLOCK_GROUP_RESERVED	(BTRFS_AVAIL_ALLOC_BIT_SINGLE | \
+					 BTRFS_SPACE_INFO_GLOBAL_RSV)
 
 enum btrfs_raid_types {
 	BTRFS_RAID_RAID10,
@@ -1017,6 +1018,12 @@ enum btrfs_raid_types {
  */
 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE	(1ULL << 48)
 
+/*
+ * A fake block group type that is used to communicate global block reserve
+ * size to userspace via the SPACE_INFO ioctl.
+ */
+#define BTRFS_SPACE_INFO_GLOBAL_RSV	(1ULL << 49)
+
 #define BTRFS_EXTENDED_PROFILE_MASK	(BTRFS_BLOCK_GROUP_PROFILE_MASK | \
 					 BTRFS_AVAIL_ALLOC_BIT_SINGLE)
 
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 383ab455bfa7..0d938f8f173e 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3465,6 +3465,11 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
 		up_read(&info->groups_sem);
 	}
 
+	/*
+	 * Global block reserve, exported as a space_info
+	 */
+	slot_count++;
+
 	/* space_slots == 0 means they are asking for a count */
 	if (space_args.space_slots == 0) {
 		space_args.total_spaces = slot_count;
@@ -3523,6 +3528,21 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
 		up_read(&info->groups_sem);
 	}
 
+	/*
+	 * Add global block reserve
+	 */
+	if (slot_count) {
+		struct btrfs_block_rsv *block_rsv = &root->fs_info->global_block_rsv;
+
+		spin_lock(&block_rsv->lock);
+		space.total_bytes = block_rsv->size;
+		space.used_bytes = block_rsv->size - block_rsv->reserved;
+		spin_unlock(&block_rsv->lock);
+		space.flags = BTRFS_SPACE_INFO_GLOBAL_RSV;
+		memcpy(dest, &space, sizeof(space));
+		space_args.total_spaces++;
+	}
+
 	user_dest = (struct btrfs_ioctl_space_info __user *)
 		(arg + sizeof(struct btrfs_ioctl_space_args));
 
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] Revert "btrfs: add ioctl to export size of global metadata reservation"
  2014-02-07 13:33 [PATCH 0/4] Btrfs updates for 3.14-rc - sysfs, ioctl David Sterba
                   ` (2 preceding siblings ...)
  2014-02-07 13:34 ` [PATCH 3/4][RFC] btrfs: export global block reserve size as space_info David Sterba
@ 2014-02-07 13:34 ` David Sterba
  3 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2014-02-07 13:34 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba, Jeff Mahoney

This reverts commit 01e219e8069516cdb98594d417b8bb8d906ed30d.

The information from the removed ioctl is newly provided by the existing
SPACE_INFO ioctl where it logically belongs and needs only minor changes
to the userspace code.

The GLOBAL_RSV ioctl hasn't been used anywhere yet, introduced only in
3.14-rc1 so there is no userspace ABI breakage.

CC: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/ioctl.c           | 16 ----------------
 include/uapi/linux/btrfs.h |  1 -
 2 files changed, 17 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 0d938f8f173e..dc64cc28af29 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3557,20 +3557,6 @@ out:
 	return ret;
 }
 
-static long btrfs_ioctl_global_rsv(struct btrfs_root *root, void __user *arg)
-{
-	struct btrfs_block_rsv *block_rsv = &root->fs_info->global_block_rsv;
-	u64 reserved;
-
-	spin_lock(&block_rsv->lock);
-	reserved = block_rsv->reserved;
-	spin_unlock(&block_rsv->lock);
-
-	if (arg && copy_to_user(arg, &reserved, sizeof(reserved)))
-		return -EFAULT;
-	return 0;
-}
-
 /*
  * there are many ways the trans_start and trans_end ioctls can lead
  * to deadlocks.  They should only be used by applications that
@@ -4777,8 +4763,6 @@ long btrfs_ioctl(struct file *file, unsigned int
 		return btrfs_ioctl_logical_to_ino(root, argp);
 	case BTRFS_IOC_SPACE_INFO:
 		return btrfs_ioctl_space_info(root, argp);
-	case BTRFS_IOC_GLOBAL_RSV:
-		return btrfs_ioctl_global_rsv(root, argp);
 	case BTRFS_IOC_SYNC: {
 		int ret;
 
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index 1b8a0f4c9590..b4d69092fbdb 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -558,7 +558,6 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)
 #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
 #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
 				    struct btrfs_ioctl_space_args)
-#define BTRFS_IOC_GLOBAL_RSV _IOR(BTRFS_IOCTL_MAGIC, 20, __u64)
 #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
 #define BTRFS_IOC_WAIT_SYNC  _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
-- 
1.8.5.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4][RFC] btrfs: export global block reserve size as space_info
  2014-02-07 13:34 ` [PATCH 3/4][RFC] btrfs: export global block reserve size as space_info David Sterba
@ 2014-02-10 17:03   ` Chris Mason
  2014-04-04 14:56     ` Jeff Mahoney
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Mason @ 2014-02-10 17:03 UTC (permalink / raw)
  To: David Sterba, linux-btrfs; +Cc: Jeff Mahoney, Josef Bacik

On 02/07/2014 08:34 AM, David Sterba wrote:
> Introduce a block group type bit for a global reserve and fill the space
> info for SPACE_INFO ioctl. This should replace the newly added ioctl
> (01e219e8069516cdb98594d417b8bb8d906ed30d) to get just the 'size' part
> of the global reserve, while the actual usage can be now visible in the
> 'btrfs fi df' output during ENOSPC stress.
>
> The unpatched userspace tools will show the blockgroup as 'unknown'.
>

This wasn't in my rc2 pull because I wanted to sync up with Jeff on it. 
  I like the idea of combining this into SPACE_INFO, any objections?

-chris

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4][RFC] btrfs: export global block reserve size as space_info
  2014-02-10 17:03   ` Chris Mason
@ 2014-04-04 14:56     ` Jeff Mahoney
  0 siblings, 0 replies; 7+ messages in thread
From: Jeff Mahoney @ 2014-04-04 14:56 UTC (permalink / raw)
  To: Chris Mason, David Sterba, linux-btrfs; +Cc: Josef Bacik

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2/10/14, 12:03 PM, Chris Mason wrote:
> On 02/07/2014 08:34 AM, David Sterba wrote:
>> Introduce a block group type bit for a global reserve and fill
>> the space info for SPACE_INFO ioctl. This should replace the
>> newly added ioctl (01e219e8069516cdb98594d417b8bb8d906ed30d) to
>> get just the 'size' part of the global reserve, while the actual
>> usage can be now visible in the 'btrfs fi df' output during
>> ENOSPC stress.
>> 
>> The unpatched userspace tools will show the blockgroup as
>> 'unknown'.
>> 
> 
> This wasn't in my rc2 pull because I wanted to sync up with Jeff on
> it. I like the idea of combining this into SPACE_INFO, any
> objections?

Sorry, was on vacation when this went by and just got the ping. Yeah,
I have no objections here.

- -Jeff

- -- 
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)

iQIcBAEBAgAGBQJTPsgMAAoJEB57S2MheeWyf1EP/158KhPm7KoT9EGeNUwv4+nb
Ex2z9hIbTduJ6rT9IG+n0vbV2Ka9IuWJDvYdoLLMIN1SFXOJdNo88MIf6aSTbHfb
WWqJJ1nMB/DnDMt1bXp6cZSGyzQuSXvI/u97Pgy3gzMpmjuzXy37c7JkFCABM352
G2IF+bZiHqa6X+eTxSjlimDKvIBOPGw/hOIvegRmqyqDMNIy5dwzDQIsytUuqsgQ
rl+fAt+R+VNdSe2ZEjn+FwviOpPrgR8TQL5Qycaoviqzd6apBtutlcJpfEIqCP8m
4guZ7bC/VjsUdJj1cxSYZe+Eh0dEas2T5qjH5DW5uyTmsKJAA3VM4lTaxITvQ0Y8
URxCQGSfAc0IUudpz+nCbLdwhUYtV/yfpA8i3Fnewyu8Jazvup0dxALo56RDu4Kf
j7K3kwTFlfB7D9/S10SbsWK3j/NR3qJu1DicG1Wy18Acl3oZvCgB4qGIaxh1vcsV
NZfkt+/5V+Mb0ocKEjdudO/sS0XNBJowMxmWOCZz6vGyKQTAWA+VYmZxJ/rKiOoG
O/YYmJ2VuzWI8KPFrhNny12UJ9AsyZLhDw4Sbr7iEDI/l/mtrL6WsK/krhMHKDdJ
wf4TWtM0CPyZS8ym6f2cgSdmvecaZ3AuK1Hd19DeMZnly6bwZV2TkNSXbfB+oAZO
HL7ZLY8oHLj4brTHFOIH
=fiJ0
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-04-04 14:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-07 13:33 [PATCH 0/4] Btrfs updates for 3.14-rc - sysfs, ioctl David Sterba
2014-02-07 13:33 ` [PATCH 1/4] btrfs: commit transaction after setting label and features David Sterba
2014-02-07 13:34 ` [PATCH 2/4] btrfs: reserve no transaction units in btrfs_ioctl_set_features David Sterba
2014-02-07 13:34 ` [PATCH 3/4][RFC] btrfs: export global block reserve size as space_info David Sterba
2014-02-10 17:03   ` Chris Mason
2014-04-04 14:56     ` Jeff Mahoney
2014-02-07 13:34 ` [PATCH 4/4] Revert "btrfs: add ioctl to export size of global metadata reservation" David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).