Re: Error compiling btrfs-tools from git (undefined reference to `pthread_create')

2012-06-29 Thread Lenz Grimmer
Hi,

thank you for your reply.

On 06/27/2012 02:20 PM, cwillu wrote:
 On Wed, Jun 27, 2012 at 6:11 AM, Lenz Grimmer l...@grimmer.com wrote:
 On Ubuntu 11.10 Oneiric with gcc 4.6.1, compiling the btrfs tools from git
 fails for me with the following error:
 
 Which git repo?
 git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs.git
 builds on ubuntu just fine (just checked on a fresh checkout), and
 likewise the integration repo (but note that the integration repo's
 master branch is not useful to build; you need to check out one of the
 actual integration branches as described on the wiki).

That's likely the issue - the following commands reproduce the compile error
for me:

git clone http://git.darksatanic.net/repo/btrfs-progs-unstable.git btrfs-progs
cd btrfs-progs
make
[...]
gcc -lpthread -g -Werror -Os -o btrfs btrfs.o btrfs_cmds.o scrub.o \
ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o 
root-tree.o
dir-item.o file-item.o inode-item.o inode-map.o crc32c.o rbtree.o
extent-cache.o extent_io.o volumes.o utils.o btrfs-list.o btrfslabel.o  -luuid
scrub.o: In function `scrub_start':
/space/tmp/btrfs-progs/scrub.c:1342: undefined reference to `pthread_create'
/space/tmp/btrfs-progs/scrub.c:1360: undefined reference to `pthread_create'
/space/tmp/btrfs-progs/scrub.c:1374: undefined reference to `pthread_join'
/space/tmp/btrfs-progs/scrub.c:1430: undefined reference to `pthread_cancel'
/space/tmp/btrfs-progs/scrub.c:1432: undefined reference to `pthread_join'
collect2: ld returned 1 exit status


However, using the integration-20120605 branch compiles fine. Thanks and sorry
for the noise!

Bye,
LenZ
-- 
  Lenz Grimmer l...@grimmer.com - http://www.lenzg.net/





signature.asc
Description: OpenPGP digital signature


[PATCH 1/4 v2] Btrfs: check write access to mount earlier while creating snapshots

2012-06-29 Thread Liu Bo
Move check of write access to mount into upper functions so that we can
use mnt_want_write_file instead, which is faster than mnt_want_write.

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 fs/btrfs/ioctl.c |   22 +++---
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 0e92e57..b5e946e 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -652,13 +652,9 @@ static noinline int btrfs_mksubvol(struct path *parent,
if (dentry-d_inode)
goto out_dput;
 
-   error = mnt_want_write(parent-mnt);
-   if (error)
-   goto out_dput;
-
error = btrfs_may_create(dir, dentry);
if (error)
-   goto out_drop_write;
+   goto out_dput;
 
down_read(BTRFS_I(dir)-root-fs_info-subvol_sem);
 
@@ -676,8 +672,6 @@ static noinline int btrfs_mksubvol(struct path *parent,
fsnotify_mkdir(dir, dentry);
 out_up_read:
up_read(BTRFS_I(dir)-root-fs_info-subvol_sem);
-out_drop_write:
-   mnt_drop_write(parent-mnt);
 out_dput:
dput(dentry);
 out_unlock:
@@ -1393,16 +1387,20 @@ static noinline int 
btrfs_ioctl_snap_create_transid(struct file *file,
if (root-fs_info-sb-s_flags  MS_RDONLY)
return -EROFS;
 
+   ret = mnt_want_write_file(file);
+   if (ret)
+   goto out;
+
namelen = strlen(name);
if (strchr(name, '/')) {
ret = -EINVAL;
-   goto out;
+   goto out_drop_write;
}
 
if (name[0] == '.' 
   (namelen == 1 || (name[1] == '.'  namelen == 2))) {
ret = -EEXIST;
-   goto out;
+   goto out_drop_write;
}
 
if (subvol) {
@@ -1413,7 +1411,7 @@ static noinline int 
btrfs_ioctl_snap_create_transid(struct file *file,
src_file = fget(fd);
if (!src_file) {
ret = -EINVAL;
-   goto out;
+   goto out_drop_write;
}
 
src_inode = src_file-f_path.dentry-d_inode;
@@ -1422,13 +1420,15 @@ static noinline int 
btrfs_ioctl_snap_create_transid(struct file *file,
   another FS\n);
ret = -EINVAL;
fput(src_file);
-   goto out;
+   goto out_drop_write;
}
ret = btrfs_mksubvol(file-f_path, name, namelen,
 BTRFS_I(src_inode)-root,
 transid, readonly);
fput(src_file);
}
+out_drop_write:
+   mnt_drop_write_file(file);
 out:
return ret;
 }
-- 
1.6.5.2

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


[PATCH 2/4 v2] Btrfs: remove redundant r/o check for superblock

2012-06-29 Thread Liu Bo
mnt_want_write() and mnt_want_write_file() will check sb-s_flags with
MS_RDONLY, and we don't need to do it ourselves.

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 fs/btrfs/ioctl.c |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index b5e946e..069cd85 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1379,14 +1379,10 @@ static noinline int 
btrfs_ioctl_snap_create_transid(struct file *file,
u64 *transid,
bool readonly)
 {
-   struct btrfs_root *root = BTRFS_I(fdentry(file)-d_inode)-root;
struct file *src_file;
int namelen;
int ret = 0;
 
-   if (root-fs_info-sb-s_flags  MS_RDONLY)
-   return -EROFS;
-
ret = mnt_want_write_file(file);
if (ret)
goto out;
@@ -3265,9 +3261,6 @@ static long btrfs_ioctl_balance(struct file *file, void 
__user *arg)
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   if (fs_info-sb-s_flags  MS_RDONLY)
-   return -EROFS;
-
ret = mnt_want_write(file-f_path.mnt);
if (ret)
return ret;
-- 
1.6.5.2

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


[PATCH 4/4 v2] Btrfs: do not set subvolume flags in readonly mode

2012-06-29 Thread Liu Bo
$ mkfs.btrfs /dev/sdb7
$ btrfstune -S1 /dev/sdb7
$ mount /dev/sdb7 /mnt/btrfs
mount: block device /dev/sdb7 is write-protected, mounting read-only
$ btrfs dev add /dev/sdb8 /mnt/btrfs/

Now we get a btrfs in which mnt flags has readonly but sb flags does
not.  So for those ioctls that only check sb flags with MS_RDONLY, it
is going to be a problem.
Setting subvolume flags is such an ioctl, we should use mnt_want_write_file()
to check RO flags.

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
v1-v2: apply Tsutomu Itoh's comments.

 fs/btrfs/ioctl.c |   42 --
 1 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index df4c04d..2cf6b1b 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1519,29 +1519,40 @@ static noinline int btrfs_ioctl_subvol_setflags(struct 
file *file,
u64 flags;
int ret = 0;
 
-   if (root-fs_info-sb-s_flags  MS_RDONLY)
-   return -EROFS;
+   ret = mnt_want_write_file(file);
+   if (ret)
+   goto out;
 
-   if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID)
-   return -EINVAL;
+   if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) {
+   ret = -EINVAL;
+   goto out_drop_write;
+   }
 
-   if (copy_from_user(flags, arg, sizeof(flags)))
-   return -EFAULT;
+   if (copy_from_user(flags, arg, sizeof(flags))) {
+   ret = -EFAULT;
+   goto out_drop_write;
+   }
 
-   if (flags  BTRFS_SUBVOL_CREATE_ASYNC)
-   return -EINVAL;
+   if (flags  BTRFS_SUBVOL_CREATE_ASYNC) {
+   ret = -EINVAL;
+   goto out_drop_write;
+   }
 
-   if (flags  ~BTRFS_SUBVOL_RDONLY)
-   return -EOPNOTSUPP;
+   if (flags  ~BTRFS_SUBVOL_RDONLY) {
+   ret = -EOPNOTSUPP;
+   goto out_drop_write;
+   }
 
-   if (!inode_owner_or_capable(inode))
-   return -EACCES;
+   if (!inode_owner_or_capable(inode)) {
+   ret = -EACCES;
+   goto out_drop_write;
+   }
 
down_write(root-fs_info-subvol_sem);
 
/* nothing to do */
if (!!(flags  BTRFS_SUBVOL_RDONLY) == btrfs_root_readonly(root))
-   goto out;
+   goto out_drop_sem;
 
root_flags = btrfs_root_flags(root-root_item);
if (flags  BTRFS_SUBVOL_RDONLY)
@@ -1564,8 +1575,11 @@ static noinline int btrfs_ioctl_subvol_setflags(struct 
file *file,
 out_reset:
if (ret)
btrfs_set_root_flags(root-root_item, root_flags);
-out:
+out_drop_sem:
up_write(root-fs_info-subvol_sem);
+out_drop_write:
+   mnt_drop_write_file(file);
+out:
return ret;
 }
 
-- 
1.6.5.2

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


[PATCH 3/4 v2] Btrfs: use mnt_want_write_file instead of mnt_want_write

2012-06-29 Thread Liu Bo
mnt_want_write_file is faster when file has been opened for write.

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 fs/btrfs/ioctl.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 069cd85..df4c04d 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3261,7 +3261,7 @@ static long btrfs_ioctl_balance(struct file *file, void 
__user *arg)
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
 
-   ret = mnt_want_write(file-f_path.mnt);
+   ret = mnt_want_write_file(file);
if (ret)
return ret;
 
@@ -3331,7 +3331,7 @@ out_bargs:
 out:
mutex_unlock(fs_info-balance_mutex);
mutex_unlock(fs_info-volume_mutex);
-   mnt_drop_write(file-f_path.mnt);
+   mnt_drop_write_file(file);
return ret;
 }
 
-- 
1.6.5.2

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


[PATCH 1/3] Btrfs-progs: add support to set subvolume/snapshot readonly

2012-06-29 Thread Liu Bo
Setting subvolume/snapshot readonly has been missing for a long time.

With this patch, we can set a subvolume/snapshot readonly via:

obtrfs subvolume set-ro path

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 cmds-subvolume.c |   40 
 ioctl.h  |7 +++
 2 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 950fa8f..5ee31cb 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -512,6 +512,44 @@ static int cmd_find_new(int argc, char **argv)
return 0;
 }
 
+static const char * const cmd_subvol_set_ro_usage[] = {
+   btrfs subvolume set-ro path,
+   Set the subvolume ro,
+   NULL
+};
+
+static int cmd_subvol_set_ro(int argc, char **argv)
+{
+   int ret=0, fd, e;
+   char*path;
+   struct  btrfs_ioctl_get_set_flags_args args;
+
+   if (check_argc_exact(argc, 2))
+   usage(cmd_subvol_set_ro_usage);
+
+   path = argv[1];
+
+   memset(args, 0, sizeof(args));
+
+   fd = open_file_or_dir(path);
+   if (fd  0) {
+   fprintf(stderr, ERROR: can't access to '%s'\n, path);
+   return 12;
+   }
+
+   args.flags |= BTRFS_SUBVOL_RDONLY;
+   args.objectid = 0;
+   ret = ioctl(fd, BTRFS_IOC_SUBVOL_SETFLAGS, args);
+   e = errno;
+   close(fd);
+   if( ret  0 ){
+   fprintf(stderr, ERROR: unable to set a subvolume RO- %s\n,
+   strerror(e));
+   return 30;
+   }
+   return 0;
+}
+
 const struct cmd_group subvolume_cmd_group = {
subvolume_cmd_group_usage, NULL, {
{ create, cmd_subvol_create, cmd_subvol_create_usage, NULL, 0 
},
@@ -522,6 +560,8 @@ const struct cmd_group subvolume_cmd_group = {
cmd_subvol_get_default_usage, NULL, 0 },
{ set-default, cmd_subvol_set_default,
cmd_subvol_set_default_usage, NULL, 0 },
+   { set-ro, cmd_subvol_set_ro,
+   cmd_subvol_set_ro_usage, NULL, 0 },
{ find-new, cmd_find_new, cmd_find_new_usage, NULL, 0 },
{ 0, 0, 0, 0, 0 }
}
diff --git a/ioctl.h b/ioctl.h
index f2e5d8d..9c066eb 100644
--- a/ioctl.h
+++ b/ioctl.h
@@ -42,6 +42,11 @@ struct btrfs_ioctl_vol_args_v2 {
char name[BTRFS_SUBVOL_NAME_MAX + 1];
 };
 
+struct btrfs_ioctl_get_set_flags_args {
+   __u64 objectid;
+   __u64 flags;
+};
+
 #define BTRFS_FSID_SIZE 16
 #define BTRFS_UUID_SIZE 16
 
@@ -312,6 +317,8 @@ struct btrfs_ioctl_logical_ino_args {
struct btrfs_ioctl_space_args)
 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
   struct btrfs_ioctl_vol_args_v2)
+#define BTRFS_IOC_SUBVOL_GETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 25, __u64)
+#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
 #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
struct btrfs_ioctl_scrub_args)
 #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
-- 
1.6.5.2

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


[PATCH 2/3] Btrfs-progs: make get default report correctly

2012-06-29 Thread Liu Bo
We have both set-default and get-default, but actually our get-default
does not show which one is the default one.

This patch plus the kernel side patch fix this.

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 Makefile |6 +++---
 btrfs-list.c |   44 +---
 cmds-subvolume.c |   16 +++-
 ioctl.h  |1 +
 4 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/Makefile b/Makefile
index 79818e6..5d10026 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ CFLAGS = -g -O0
 objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
  root-tree.o dir-item.o file-item.o inode-item.o \
  inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \
- volumes.o utils.o btrfs-list.o btrfslabel.o repair.o
+ volumes.o utils.o btrfs-list.o btrfslabel.o repair.o common.o
 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
   cmds-inspect.o cmds-balance.o
 
@@ -39,8 +39,8 @@ all: version $(progs) manpages
 version:
bash version.sh
 
-btrfs: $(objects) btrfs.o help.o common.o $(cmds_objects)
-   $(CC) $(CFLAGS) -o btrfs btrfs.o help.o common.o $(cmds_objects) \
+btrfs: $(objects) btrfs.o help.o $(cmds_objects)
+   $(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \
$(objects) $(LDFLAGS) $(LIBS) -lpthread
 
 calc-size: $(objects) calc-size.o
diff --git a/btrfs-list.c b/btrfs-list.c
index 5f4a9be..f1baa52 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -34,6 +34,7 @@
 #include ctree.h
 #include transaction.h
 #include utils.h
+#include commands.h
 
 /* we store all the roots we find in an rbtree so that we can
  * search for them later.
@@ -668,7 +669,42 @@ static int __list_subvol_fill_paths(int fd, struct 
root_lookup *root_lookup)
return 0;
 }
 
-int list_subvols(int fd, int print_parent)
+int subvol_get_set_flags(int fd, int set, u64 flags, u64 root_id)
+{
+   int ret = 0, e;
+   struct btrfs_ioctl_get_set_flags_args args;
+
+   memset(args, 0, sizeof(args));
+
+   if (set  flags)
+   args.flags |= flags;
+   args.objectid = root_id;
+
+   if (set)
+   ret = ioctl(fd, BTRFS_IOC_SUBVOL_SETFLAGS, args);
+   else
+   ret = ioctl(fd, BTRFS_IOC_SUBVOL_GETFLAGS, args);
+   e = errno;
+   if( ret  0 ){
+   fprintf(stderr, ERROR: unable to %s a subvolume flags- %s\n,
+   (set) ? set : get, strerror(e));
+   return 30;
+   } else if (!set) {
+   u64 flags_to_get = args.flags;
+   if (flags_to_get)
+   printf( ();
+   if (flags_to_get  BTRFS_SUBVOL_RDONLY)
+   printf(Readonly,);
+   if (flags_to_get  BTRFS_SUBVOL_DEFAULT)
+   printf(Default,);
+   if (flags_to_get)
+   printf());
+   printf(\n);
+   }
+   return 0;
+}
+
+int list_subvols(int fd, int print_parent, int get_default)
 {
struct root_lookup root_lookup;
struct rb_node *n;
@@ -704,15 +740,17 @@ int list_subvols(int fd, int print_parent)
resolve_root(root_lookup, entry, root_id, parent_id,
level, path);
if (print_parent) {
-   printf(ID %llu parent %llu top level %llu path %s\n,
+   printf(ID %llu parent %llu top level %llu path %s,
(unsigned long long)root_id,
(unsigned long long)parent_id,
(unsigned long long)level, path);
} else {
-   printf(ID %llu top level %llu path %s\n,
+   printf(ID %llu top level %llu path %s,
(unsigned long long)root_id,
(unsigned long long)level, path);
}
+   if (subvol_get_set_flags(fd, 0, 0, root_id))
+   printf(\n);
free(path);
n = rb_prev(n);
}
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 5ee31cb..8783e67 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -32,6 +32,7 @@
 /* btrfs-list.c */
 int list_subvols(int fd, int print_parent, int get_default);
 int find_updated_files(int fd, u64 root_id, u64 oldest_gen);
+int subvol_get_set_flags(int fd, int set, u64 flags, u64 root_id);
 
 static const char * const subvolume_cmd_group_usage[] = {
btrfs subvolume command args,
@@ -520,33 +521,22 @@ static const char * const cmd_subvol_set_ro_usage[] = {
 
 static int cmd_subvol_set_ro(int argc, char **argv)
 {
-   int ret=0, fd, e;
+   int ret=0, fd;
char*path;
-   struct  btrfs_ioctl_get_set_flags_args args;
 
if (check_argc_exact(argc, 2))

[PATCH 3/3] Btrfs-progs: add 's' option for 'btrfs subvolume list'

2012-06-29 Thread Liu Bo
We want 'btrfs subvolume list' to act as 'ls', which means that
we can not only list out all the subvolumes we have, but also list
each single one.

So this patch add 's' option to show a single one:

$ ./btrfs sub list /mnt/btrfs/
ID 256 top level 5 path subvol (Readonly,)
ID 257 top level 5 path snapshot
ID 258 top level 5 path subvol2
ID 259 top level 5 path subvol2/subvol3

$ ./btrfs sub list -s /mnt/btrfs/subvol
ID 256 top level 5 path subvol (Readonly,)

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 btrfs-list.c |   41 -
 cmds-subvolume.c |   15 ++-
 2 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/btrfs-list.c b/btrfs-list.c
index f1baa52..3e79239 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -312,6 +312,30 @@ static int lookup_ino_path(int fd, struct root_info *ri)
return 0;
 }
 
+/*
+ * helper function for getting the root which the file is belonged to.
+ */
+static int lookup_ino_rootid(int fd, u64 *rootid)
+{
+   struct btrfs_ioctl_ino_lookup_args args;
+   int ret, e;
+
+   memset(args, 0, sizeof(args));
+   args.treeid = 0;
+   args.objectid = BTRFS_FIRST_FREE_OBJECTID;
+
+   ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, args);
+   e = errno;
+   if (ret) {
+   fprintf(stderr, ERROR: Failed to lookup root id - %s\n,
+   strerror(e));
+   return ret;
+   }
+
+   *rootid = args.treeid;
+   return 0;
+}
+
 /* finding the generation for a given path is a two step process.
  * First we use the inode loookup routine to find out the root id
  *
@@ -704,11 +728,12 @@ int subvol_get_set_flags(int fd, int set, u64 flags, u64 
root_id)
return 0;
 }
 
-int list_subvols(int fd, int print_parent, int get_default)
+int list_subvols(int fd, int print_parent, int print_self, int get_default)
 {
struct root_lookup root_lookup;
struct rb_node *n;
int ret;
+   u64 subvolid = 0;
 
ret = __list_subvol_search(fd, root_lookup);
if (ret) {
@@ -725,6 +750,9 @@ int list_subvols(int fd, int print_parent, int get_default)
if (ret  0)
return ret;
 
+   if (print_self)
+   lookup_ino_rootid(fd, subvolid);
+
/* now that we have all the subvol-relative paths filled in,
 * we have to string the subvols together so that we can get
 * a path all the way back to the FS root
@@ -739,6 +767,14 @@ int list_subvols(int fd, int print_parent, int get_default)
entry = rb_entry(n, struct root_info, rb_node);
resolve_root(root_lookup, entry, root_id, parent_id,
level, path);
+
+   /* print this subvolume only */
+   if (print_self  subvolid != root_id) {
+   free(path);
+   n = rb_prev(n);
+   continue;
+   }
+
if (print_parent) {
printf(ID %llu parent %llu top level %llu path %s,
(unsigned long long)root_id,
@@ -753,6 +789,9 @@ int list_subvols(int fd, int print_parent, int get_default)
printf(\n);
free(path);
n = rb_prev(n);
+
+   if (print_self)
+   break;
}
 
return ret;
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 8783e67..f779b78 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -30,7 +30,7 @@
 #include commands.h
 
 /* btrfs-list.c */
-int list_subvols(int fd, int print_parent, int get_default);
+int list_subvols(int fd, int print_parent, int print_self, int get_default);
 int find_updated_files(int fd, u64 root_id, u64 oldest_gen);
 int subvol_get_set_flags(int fd, int set, u64 flags, u64 root_id);
 
@@ -218,10 +218,11 @@ static int cmd_subvol_delete(int argc, char **argv)
 }
 
 static const char * const cmd_subvol_list_usage[] = {
-   btrfs subvolume list [-p] path,
+   btrfs subvolume list [-ps] path,
List subvolumes (and snapshots),
,
-p print parent ID,
+   -s print this subvolume only,
NULL
 };
 
@@ -230,11 +231,12 @@ static int cmd_subvol_list(int argc, char **argv)
int fd;
int ret;
int print_parent = 0;
+   int print_self = 0;
char *subvol;
 
optind = 1;
while(1) {
-   int c = getopt(argc, argv, p);
+   int c = getopt(argc, argv, ps);
if (c  0)
break;
 
@@ -242,6 +244,9 @@ static int cmd_subvol_list(int argc, char **argv)
case 'p':
print_parent = 1;
break;
+   case 's':
+   print_self = 1;
+   break;
default:
usage(cmd_subvol_list_usage);
}
@@ -267,7 +272,7 @@ static 

[PATCH 3/3] Btrfs: use helper function to simplify code

2012-06-29 Thread Liu Bo
We've made a helper function for reading root, so just apply it.

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 fs/btrfs/ioctl.c |   13 +
 1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f9c2180..9b93fda 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2844,7 +2844,6 @@ static long btrfs_ioctl_default_subvol(struct file *file, 
void __user *argp)
struct btrfs_dir_item *di;
struct btrfs_trans_handle *trans;
struct btrfs_path *path;
-   struct btrfs_key location;
struct btrfs_disk_key disk_key;
struct btrfs_super_block *disk_super;
u64 features;
@@ -2857,20 +2856,10 @@ static long btrfs_ioctl_default_subvol(struct file 
*file, void __user *argp)
if (copy_from_user(objectid, argp, sizeof(objectid)))
return -EFAULT;
 
-   if (!objectid)
-   objectid = root-root_key.objectid;
-
-   location.objectid = objectid;
-   location.type = BTRFS_ROOT_ITEM_KEY;
-   location.offset = (u64)-1;
-
-   new_root = btrfs_read_fs_root_no_name(root-fs_info, location);
+   new_root = __btrfs_subvol_get_root(root, objectid);
if (IS_ERR(new_root))
return PTR_ERR(new_root);
 
-   if (btrfs_root_refs(new_root-root_item) == 0)
-   return -ENOENT;
-
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
-- 
1.6.5.2

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


[PATCH 1/3] Btrfs: add default support for subvol getflags

2012-06-29 Thread Liu Bo
This is kernel side patch for 'btrfs subvolume get-default'.

Our 'btrfs subvolume get-default' did not work as wish, because we do not have
APIs to fetch the subvolume's default state.

This patch treats default state as a flag and returns it to user space.

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 fs/btrfs/ioctl.c |   37 +
 fs/btrfs/ioctl.h |1 +
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 2cf6b1b..60fff96 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1487,6 +1487,39 @@ out:
return ret;
 }
 
+/* Return 1 for default, otherwise return 0. */
+static int btrfs_root_default(struct btrfs_root *root)
+{
+   struct btrfs_path *path;
+   struct btrfs_disk_key disk_key;
+   struct btrfs_key key;
+   struct btrfs_dir_item *di;
+   int is_default = 0;
+   u64 dir_id;
+
+   path = btrfs_alloc_path();
+   if (!path)
+   return -ENOMEM;
+
+   dir_id = btrfs_super_root_dir(root-fs_info-super_copy);
+   di = btrfs_lookup_dir_item(NULL, root-fs_info-tree_root, path,
+  dir_id, default, 7, 0);
+   if (IS_ERR_OR_NULL(di)) {
+   btrfs_free_path(path);
+   printk(KERN_ERR Umm, no default dir item!\n);
+   return -ENOENT;
+   }
+   btrfs_dir_item_key(path-nodes[0], di, disk_key);
+   btrfs_disk_key_to_cpu(key, disk_key);
+   if (btrfs_comp_cpu_keys(key, root-root_key))
+   is_default = 0;
+   else
+   is_default = 1;
+
+   btrfs_free_path(path);
+   return is_default;
+}
+
 static noinline int btrfs_ioctl_subvol_getflags(struct file *file,
void __user *arg)
 {
@@ -1501,6 +1534,10 @@ static noinline int btrfs_ioctl_subvol_getflags(struct 
file *file,
down_read(root-fs_info-subvol_sem);
if (btrfs_root_readonly(root))
flags |= BTRFS_SUBVOL_RDONLY;
+
+   ret = btrfs_root_default(root);
+   if (ret  0)
+   flags |= BTRFS_SUBVOL_DEFAULT;
up_read(root-fs_info-subvol_sem);
 
if (copy_to_user(arg, flags, sizeof(flags)))
diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
index 497c530..3186d2d 100644
--- a/fs/btrfs/ioctl.h
+++ b/fs/btrfs/ioctl.h
@@ -32,6 +32,7 @@ struct btrfs_ioctl_vol_args {
 
 #define BTRFS_SUBVOL_CREATE_ASYNC  (1ULL  0)
 #define BTRFS_SUBVOL_RDONLY(1ULL  1)
+#define BTRFS_SUBVOL_DEFAULT   (1ULL  2)
 #define BTRFS_FSID_SIZE 16
 #define BTRFS_UUID_SIZE 16
 
-- 
1.6.5.2

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


[PATCH 2/3] Btrfs: update subvol_getflags/setflags to know new args from user

2012-06-29 Thread Liu Bo
I've modified 'btrfs subvolume list' to show a subvolume's attributes,
such as readonly and default, and adopted a new structure for args for
subvol_getflags/setflags.

So here is the kernel side update.

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 fs/btrfs/ioctl.c |  100 -
 fs/btrfs/ioctl.h |5 +++
 2 files changed, 80 insertions(+), 25 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 60fff96..f9c2180 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1487,6 +1487,31 @@ out:
return ret;
 }
 
+static struct btrfs_root *__btrfs_subvol_get_root(struct btrfs_root *root,
+ u64 root_id)
+{
+   struct btrfs_key root_key;
+   struct btrfs_root *root_ret = NULL;
+
+   if (root-objectid == root_id || !root_id) {
+   root_ret = root;
+   goto get_root;
+   }
+
+   root_key.objectid = root_id;
+   root_key.type = BTRFS_ROOT_ITEM_KEY;
+   root_key.offset = (u64)-1;
+   root_ret = btrfs_read_fs_root_no_name(root-fs_info, root_key);
+   /* root_ret won't be NULL */
+   if (IS_ERR(root_ret))
+   return root_ret;
+get_root:
+   if (btrfs_root_refs(root_ret-root_item) == 0)
+   return ERR_PTR(-ENOENT);
+
+   return root_ret;
+}
+
 /* Return 1 for default, otherwise return 0. */ 
 static int btrfs_root_default(struct btrfs_root *root)
 {
@@ -1525,24 +1550,38 @@ static noinline int btrfs_ioctl_subvol_getflags(struct 
file *file,
 {
struct inode *inode = fdentry(file)-d_inode;
struct btrfs_root *root = BTRFS_I(inode)-root;
+   struct btrfs_root *new_root = NULL;
int ret = 0;
-   u64 flags = 0;
+   struct btrfs_ioctl_get_set_flags_args *get_args;
 
if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID)
return -EINVAL;
 
-   down_read(root-fs_info-subvol_sem);
-   if (btrfs_root_readonly(root))
-   flags |= BTRFS_SUBVOL_RDONLY;
+   get_args = memdup_user(arg, sizeof(*get_args));
+   if (IS_ERR(get_args))
+   return PTR_ERR(get_args);
 
-   ret = btrfs_root_default(root);
-   if (ret  0)
-   flags |= BTRFS_SUBVOL_DEFAULT;
-   up_read(root-fs_info-subvol_sem);
+   new_root = __btrfs_subvol_get_root(root, get_args-objectid);
+   if (IS_ERR(new_root)) {
+   ret = PTR_ERR(new_root);
+   goto out;
+   }
 
-   if (copy_to_user(arg, flags, sizeof(flags)))
+   down_read(new_root-fs_info-subvol_sem);
+   if (btrfs_root_readonly(new_root))
+   get_args-flags |= BTRFS_SUBVOL_RDONLY;
+   ret = btrfs_root_default(new_root);
+   if (ret  0) {
+   get_args-flags |= BTRFS_SUBVOL_DEFAULT;
+   ret = 0;
+   }
+   up_read(new_root-fs_info-subvol_sem);
+
+   if (copy_to_user(arg, get_args, sizeof(*get_args)))
ret = -EFAULT;
 
+out:
+   kfree(get_args);
return ret;
 }
 
@@ -1551,8 +1590,10 @@ static noinline int btrfs_ioctl_subvol_setflags(struct 
file *file,
 {
struct inode *inode = fdentry(file)-d_inode;
struct btrfs_root *root = BTRFS_I(inode)-root;
+   struct btrfs_root *new_root = NULL;
struct btrfs_trans_handle *trans;
-   u64 root_flags;
+   struct btrfs_ioctl_get_set_flags_args *set_args = NULL;
+   u64 root_flags, new_root_flags;
u64 flags;
int ret = 0;
 
@@ -1565,11 +1606,19 @@ static noinline int btrfs_ioctl_subvol_setflags(struct 
file *file,
goto out_drop_write;
}
 
-   if (copy_from_user(flags, arg, sizeof(flags))) {
-   ret = -EFAULT;
+   set_args = memdup_user(arg, sizeof(*set_args));
+   if (IS_ERR(set_args)) {
+   ret = PTR_ERR(set_args);
+   goto out_drop_write;
+   }
+
+   new_root = __btrfs_subvol_get_root(root, set_args-objectid);
+   if (IS_ERR(new_root)) {
+   ret = PTR_ERR(new_root);
goto out_drop_write;
}
 
+   flags = set_args-flags;
if (flags  BTRFS_SUBVOL_CREATE_ASYNC) {
ret = -EINVAL;
goto out_drop_write;
@@ -1585,38 +1634,39 @@ static noinline int btrfs_ioctl_subvol_setflags(struct 
file *file,
goto out_drop_write;
}
 
-   down_write(root-fs_info-subvol_sem);
+   down_write(new_root-fs_info-subvol_sem);
 
/* nothing to do */
-   if (!!(flags  BTRFS_SUBVOL_RDONLY) == btrfs_root_readonly(root))
+   if (!!(flags  BTRFS_SUBVOL_RDONLY) == btrfs_root_readonly(new_root))
goto out_drop_sem;
 
-   root_flags = btrfs_root_flags(root-root_item);
+   new_root_flags = root_flags = btrfs_root_flags(new_root-root_item);
if (flags  BTRFS_SUBVOL_RDONLY)
-   btrfs_set_root_flags(root-root_item,
-root_flags | 

Re: [PATCH 1/3] Btrfs-progs: add support to set subvolume/snapshot readonly

2012-06-29 Thread Ilya Dryomov
On Fri, Jun 29, 2012 at 06:00:36PM +0800, Liu Bo wrote:
 Setting subvolume/snapshot readonly has been missing for a long time.
 
 With this patch, we can set a subvolume/snapshot readonly via:
 
 obtrfs subvolume set-ro path

Alexander's 'btrfs property' patches do exactly this, but in a much more
generic and extensible way.  'btrfs property' subgroup provides a
uniform interface for getting and setting properties of filesystem
objects in general, not only those of subvolumes and snapshots.  It
provides a much better user interface, and it also allows us to easily
rethink kernel-user interface for generic get/set in future.

Thanks,

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


Kernel panic from btrfs subvolume delete

2012-06-29 Thread Richard Cooper
Hi All,

I have two machines where I've been testing various btrfs based backup 
strategies. They are both Cent OS 6 with the standard kernel and btrfs-progs 
RPMs from the CentOS repos.

- kernel-2.6.32-220.17.1.el6.x86_64
- btrfs-progs-0.19-12.el6.x86_64

Both are currently in a state when trying to delete a subvolume results in the 
following kernel panic.

--

[root@backup2 ~]# btrfs subvolume delete /srv/backup_history/2012-06-28-1342
Delete subvolume '/srv/backup_history/2012-06-28-1342'
[root@backup2 ~]# 
Message from syslogd@backup2 at Jun 29 08:53:06 ...
 kernel:[ cut here ]

Message from syslogd@backup2 at Jun 29 08:53:06 ...
 kernel:invalid opcode:  [#1] SMP 

Message from syslogd@backup2 at Jun 29 08:53:06 ...
 kernel:last sysfs file: /sys/devices/virtual/block/md1/md/metadata_version

Message from syslogd@backup2 at Jun 29 08:53:06 ...
 kernel:Stack:

Message from syslogd@backup2 at Jun 29 08:53:06 ...
 kernel:Call Trace:

Message from syslogd@backup2 at Jun 29 08:53:06 ...
 kernel:Code: 89 ef e8 84 f5 fe ff 48 89 df 89 45 d8 e8 99 86 fe ff 8b 45 d8 48 
8b 5d e0 4c 8b 65 e8 4c 8b 6d f0 4c 8b 75 f8 c9 c3 0f 0b eb fe 0f 0b eb fe 0f 
0b 66 2e 0f 1f 84 00 00 00 00 00 eb f4 66 66 66 

Message from syslogd@backup2 at Jun 29 08:53:06 ...
 kernel:Kernel panic - not syncing: Fatal exception

--

Sometimes the kernel:last sysfs file line says /sys/kernel/kexec_crash_loaded 
instead.

My setup is that /srv is a btrfs sat on /dev/md4 which is a 4 drive software 
RAID5 array. /srv/backups/data is a subvolume containing 65GB worth of test 
data. I've btrfs subvolume snapshoted that data to a few new subvolumes under 
 /srv/backup_history/. Now whenever I try to delete any of the snapshots on 
either machine I get a kernel panic.

btrfsck look like this:

[root@backup2 ~]# btrfsck /dev/md4
found 72254246912 bytes used err is 0
total csum bytes: 66815432
total tree bytes: 3835244544
total fs tree bytes: 358144
btree space waste bytes: 1187313778
file data blocks allocated: 68419002368
 referenced 68418383872
Btrfs Btrfs v0.19


What should I do now? Do I need to upgrade to a more recent btrfs? If so, how? 
Can I provide any more information to help debug and fix the problem?

Regards,

- Rich

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


Re: [PATCH 2/3] Btrfs-progs: make get default report correctly

2012-06-29 Thread Ilya Dryomov
On Fri, Jun 29, 2012 at 06:00:37PM +0800, Liu Bo wrote:
 We have both set-default and get-default, but actually our get-default
 does not show which one is the default one.
 
 This patch plus the kernel side patch fix this.

Are you referring to the fact that get-default in Chris' btrfs-progs
master lists all subvolumes instead of showing the default one?  If so,
I fixed that problem a while ago, patch is in Hugo's integration branch.

Thanks,

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


Re: Kernel panic from btrfs subvolume delete

2012-06-29 Thread Fajar A. Nugraha
On Fri, Jun 29, 2012 at 5:11 PM, Richard Cooper
rich...@richardcooper.net wrote:
 Hi All,

 I have two machines where I've been testing various btrfs based backup 
 strategies. They are both Cent OS 6 with the standard kernel and btrfs-progs 
 RPMs from the CentOS repos.

 - kernel-2.6.32-220.17.1.el6.x86_64
 - btrfs-progs-0.19-12.el6.x86_64

In btrfs terms, 2.6.32 is ... stone age :P

 What should I do now? Do I need to upgrade to a more recent btrfs?

Yep

 If so, how?

https://blogs.oracle.com/linux/entry/oracle_unbreakable_enterprise_kernel_release
http://elrepo.org/tiki/kernel-ml

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


Re: Kernel panic from btrfs subvolume delete

2012-06-29 Thread Duncan
Fajar A. Nugraha posted on Fri, 29 Jun 2012 17:42:26 +0700 as excerpted:

 On Fri, Jun 29, 2012 at 5:11 PM, Richard Cooper
 rich...@richardcooper.net wrote:
 Hi All,

 I have two machines where I've been testing various btrfs based backup
 strategies. They are both Cent OS 6 with the standard kernel and
 btrfs-progs RPMs from the CentOS repos.

 - kernel-2.6.32-220.17.1.el6.x86_64 - btrfs-progs-0.19-12.el6.x86_64
 
 In btrfs terms, 2.6.32 is ... stone age :P

Indeed!  As both the kernel option and the btrfs wiki state, btrfs is an 
experimental filesystem under heavy development and fit for testing, not 
operational use.  Oracle and I believe SuSE have paid support now if you 
want it, but to some extent that's by locking down your options, and 
otherwise, it's simply offering to let you pay them for recovery efforts 
if something does go wrong.

Meanwhile, under heavy development in practice means that if you're 
using a kernel older than the last upstream release or two (so 3.3 at the 
very oldest!), you're testing extremely outdated code and the value of 
those tests both in reporting problems and in conclusions you yourself 
may draw from them is extremely limited.

Latest upstream release, now 3.4, is really the oldest you should be 
running for btrfs testing, and many people run the development kernel rcs, 
3.5-rc4 currently, or git-kernels, either Linus or btrfs-next (see the 
wiki).

So 2.6.32...  Do you still run kernel 2.2 on your non-btrfs machines, by 
any chance?  Because that's what's comparable, in terms of btrfs 
development vs kernel development.

 What should I do now? Do I need to upgrade to a more recent btrfs?
 
 Yep
 
 If so, how?
 
 https://blogs.oracle.com/linux/entry/
oracle_unbreakable_enterprise_kernel_release
 http://elrepo.org/tiki/kernel-ml


Or read up on the wiki and go mainline kernel:

https://btrfs.wiki.kernel.org/

https://btrfs.wiki.kernel.org/index.php/Main_Page#Documentation

https://btrfs.wiki.kernel.org/index.php/Btrfs_source_repositories

-- 
Duncan - List replies preferred.   No HTML msgs.
Every nonfree program has a lord, a master --
and if you use the program, he is your master.  Richard Stallman

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


Re: [PATCH] Btrfs: fix dio write vs buffered read race V2

2012-06-29 Thread Chris Mason
On Thu, Jun 28, 2012 at 08:18:35PM -0600, Miao Xie wrote:
 On Thu, 28 Jun 2012 08:34:23 -0400, Josef Bacik wrote:
  On Wed, Jun 27, 2012 at 09:35:08PM -0600, Miao Xie wrote:
  On Tue, 26 Jun 2012 09:42:56 -0400, Josef Bacik wrote:
  From: Josef Bacik jo...@redhat.com
 
  Miao pointed out there's a problem with mixing dio writes and buffered
  reads.  If the read happens between us invalidating the page range and
  actually locking the extent we can bring in pages into page cache.  Then
  once the write finishes if somebody tries to read again it will just find
  uptodate pages and we'll read stale data.  So we need to lock the extent 
  and
  check for uptodate bits in the range.  If there are uptodate bits we need 
  to
  unlock and invalidate again.  This will keep this race from happening 
  since
  we will hold the extent locked until we create the ordered extent, and 
  then
  teh read side always waits for ordered extents.  Thanks,
 
  This patch still can not work well. It is because we don't update i_size 
  in time.
 Writer  Worker  Reader
 lock_extent
 do direct io
 end io
 finish io
 unlock_extent
 lock_extent
 check the pos is beyond EOF or not
   beyond EOF, zero the page and set it 
  uptodate
 unlock_extent
 update i_size
 
  So I think we must update the i_size in time, and I wrote a small patch to 
  do it:
 
  
  We should probably be updating i_size when we create an extent past EOF in 
  the
  write stuff, not during endio, I will work this out and fold it into my 
  patch.
  Good catch.
 
 It is better that update i_size in endio, I think. because during endio, we 
 are sure that
 the data is flushed into the disk successfully, and can update i_size at 
 ease. and if the
 error happens when flushing the data into the disk, we also needn't reset 
 i_size.

I think the i_size update should happen sooner.  The rest of the
filesystems work that way, and it will have fewer interaction problems
with the VM.

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


Can give some help?

2012-06-29 Thread Zhi Yong Wu
HI,

Can anyone let me know where the funtions are declared or defined,
such as btrfs_header_nritems(), btrfs_header_level(), etc? thanks.

-- 
Regards,

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


Re: Can give some help?

2012-06-29 Thread Hugo Mills
On Fri, Jun 29, 2012 at 09:41:47PM +0800, Zhi Yong Wu wrote:
 HI,
 
 Can anyone let me know where the funtions are declared or defined,
 such as btrfs_header_nritems(), btrfs_header_level(), etc? thanks.

   ctree.h, somewhere around or after line 1550. They're all accessor
functions, defined by a set of macros. Look for the *_SETGET_* macros.
The actual definitions of BTRFS_SETGET_FUNCS are in struct-funcs.h

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
   --- Great oxymorons of the world, no. 1: Family Holiday ---   


signature.asc
Description: Digital signature


Re: Can give some help?

2012-06-29 Thread Zhi Yong Wu
On Fri, Jun 29, 2012 at 9:47 PM, Hugo Mills h...@carfax.org.uk wrote:
 On Fri, Jun 29, 2012 at 09:41:47PM +0800, Zhi Yong Wu wrote:
 HI,

 Can anyone let me know where the funtions are declared or defined,
 such as btrfs_header_nritems(), btrfs_header_level(), etc? thanks.

   ctree.h, somewhere around or after line 1550. They're all accessor
 functions, defined by a set of macros. Look for the *_SETGET_* macros.
 The actual definitions of BTRFS_SETGET_FUNCS are in struct-funcs.h
Great, thanks.


   Hugo.

 --
 === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
       --- Great oxymorons of the world, no. 1: Family Holiday ---



-- 
Regards,

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


Re: Kernel panic from btrfs subvolume delete

2012-06-29 Thread Richard Cooper

On 29 Jun 2012, at 11:42, Fajar A. Nugraha wrote:
 What should I do now? Do I need to upgrade to a more recent btrfs?
 
 Yep
 
 If so, how?
 
 https://blogs.oracle.com/linux/entry/oracle_unbreakable_enterprise_kernel_release
 http://elrepo.org/tiki/kernel-ml

Perfect, thank you! I was looking for a mainline kernel yum repo but my 
google-fu was failing me. That looks like just what I need.

I've installed kernel v3.4.4 from http://elrepo.org/tiki/kernel-ml and that 
seems to have fixed my kernel panic. I'm still using the default Cent OS 6 
versions of the btrfs userspace programs (v0.19). Any reason why that might be 
a bad idea?

Thanks again,

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


Re: Kernel panic from btrfs subvolume delete

2012-06-29 Thread Fajar A. Nugraha
On Fri, Jun 29, 2012 at 9:23 PM, Richard Cooper
rich...@richardcooper.net wrote:
 If so, how?

 https://blogs.oracle.com/linux/entry/oracle_unbreakable_enterprise_kernel_release
 http://elrepo.org/tiki/kernel-ml

 Perfect, thank you! I was looking for a mainline kernel yum repo but my 
 google-fu was failing me. That looks like just what I need.

 I've installed kernel v3.4.4 from http://elrepo.org/tiki/kernel-ml and that 
 seems to have fixed my kernel panic. I'm still using the default Cent OS 6 
 versions of the btrfs userspace programs (v0.19). Any reason why that might 
 be a bad idea?

At the very least, newer version of btrfsck has --repair, which you
might need later in the future.
There's also features lke forcing a certain compression (e.g. zlib) on
a file as part of btrfs filesystem defrag command.

Just grab updated btrfs-progs (or whatever it's called) from Oracle's repo.

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


Re: Kernel panic from btrfs subvolume delete

2012-06-29 Thread Hugo Mills
On Fri, Jun 29, 2012 at 03:23:13PM +0100, Richard Cooper wrote:
 
 On 29 Jun 2012, at 11:42, Fajar A. Nugraha wrote:
  What should I do now? Do I need to upgrade to a more recent btrfs?
  
  Yep
  
  If so, how?
  
  https://blogs.oracle.com/linux/entry/oracle_unbreakable_enterprise_kernel_release
  http://elrepo.org/tiki/kernel-ml
 
 Perfect, thank you! I was looking for a mainline kernel yum repo but my 
 google-fu was failing me. That looks like just what I need.
 
 I've installed kernel v3.4.4 from http://elrepo.org/tiki/kernel-ml and that 
 seems to have fixed my kernel panic. I'm still using the default Cent OS 6 
 versions of the btrfs userspace programs (v0.19). Any reason why that might 
 be a bad idea?

   You miss out on new features (like scrub and btrfsck). Note that
0.19 could actually be any version from the last 3 years or so. Most
distributions these days are putting a date in their package names --
anything from 20120328 or so is good.

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
   --- Charting the inexorable advance of Western syphilisation... ---   


signature.asc
Description: Digital signature