Re: [PATCH v2] btrfs-progs: mkfs should check for small vol well before

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






On 08/31/2013 07:22 AM, David Sterba wrote:
On Fri, Aug 30, 2013 at 04:50:37PM +0800, Anand Jain wrote:
This fix the regression introduced by 830427d

ie. that's
"btrfs-progs: avoid write to the disk before sure to create fs"

please note that the commit id is not stable and may change during
integration branch updates.

I was not sure if the patch is all ok and had put it into
integration-next branch (that serves me as a unstable area for things
that I'd like to look at again). The patch caused Josef some headaches
and I've left it out from recent integration branches until the problems
are resolved. With the patch in this email you do so, but let me do more
testing and then I'll integrate it.

 Thanks for taking care of this David. Let me know if anywhere
 needs more explanation.
 I have been introducing series of device related changes in
 btrfs-progs/mkfs which were/is essential bug fix. Fixes looks
 complex since originally btrfs-progs/mkfs didn't create and
 use much of helper functions in this area, now with these
 fixes its much modular and better.


--- a/utils.c
+++ b/utils.c
@@ -1964,3 +1964,32 @@ int scan_for_btrfs(int where, int update_kernel)
+int is_vol_small(char *file)
+{
+	int fd = -1;
+	int e;
+	struct stat st;
+	u64 size;
+
+	fd = open(file, O_RDONLY);
+	if (fd < 0)
+		return -errno;
+	if (fstat(fd, &st) < 0) {
+		e = -errno;
+		close(fd);
+		return e;
+	}
+	size = btrfs_device_size(fd, &st);
+	if (size == 0) {
+		close(fd);
+		return -1;
+	}
+	if (size < 1024 * 1024 * 1024) {

Would be good to use a properly named constant instead of the magic
number.

 Yeah I notice that, but didn't want to change from the Original.
 There are other places where this constant is needed as well,
 will spin a separate patch for that hope that's fine.

Thanks
Anand

thanks,
david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux