* [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable
@ 2012-09-14 5:50 anand jain
2012-09-14 6:04 ` [PATCH] Btrfs-progs: make dump_thread and write_buf usable outside cmds-send.c Anand jain
2012-09-14 11:04 ` [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable David Sterba
0 siblings, 2 replies; 11+ messages in thread
From: anand jain @ 2012-09-14 5:50 UTC (permalink / raw)
To: linux-btrfs
btrfs send introduced a part of code to read kernel-data
from user-end using pipe. We need this part of code to be
useable outside of send sub-cmd, so that developing
service sub-cmd can use it.
Following this email are the patches for this purpose.
Thanks, Anand
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] Btrfs-progs: make dump_thread and write_buf usable outside cmds-send.c
2012-09-14 5:50 [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable anand jain
@ 2012-09-14 6:04 ` Anand jain
2012-09-14 6:04 ` [PATCH] Btrfs-progs: making send.h inline with its kernel side change Anand jain
2012-09-14 6:04 ` [PATCH] Btrfs: write_buf is now callable outside send.c Anand jain
2012-09-14 11:04 ` [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable David Sterba
1 sibling, 2 replies; 11+ messages in thread
From: Anand jain @ 2012-09-14 6:04 UTC (permalink / raw)
To: linux-btrfs; +Cc: chris.mason, hugo
From: Anand Jain <anand.jain@oracle.com>
Developing service cmds needs it.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
cmds-send.c | 15 +++++++++------
commands.h | 8 ++++++++
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/cmds-send.c b/cmds-send.c
index 41ea523..9e94410 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -175,7 +175,7 @@ static void add_clone_source(struct btrfs_send *s, u64 root_id)
s->clone_sources[s->clone_sources_count++] = root_id;
}
-static int write_buf(int fd, const void *buf, int size)
+int write_buf(int fd, const void *buf, int size)
{
int ret;
int pos = 0;
@@ -202,15 +202,15 @@ out:
return ret;
}
-static void *dump_thread(void *arg_)
+void *dump_thread(void *arg_)
{
int ret;
- struct btrfs_send *s = (struct btrfs_send*)arg_;
+ struct btrfs_dump *d = (struct btrfs_dump*)arg_;
char buf[4096];
int readed;
while (1) {
- readed = read(s->send_fd, buf, sizeof(buf));
+ readed = read(d->from_fd, buf, sizeof(buf));
if (readed < 0) {
ret = -errno;
fprintf(stderr, "ERROR: failed to read stream from "
@@ -221,7 +221,7 @@ static void *dump_thread(void *arg_)
ret = 0;
goto out;
}
- ret = write_buf(s->dump_fd, buf, readed);
+ ret = write_buf(d->to_fd, buf, readed);
if (ret < 0)
goto out;
}
@@ -241,6 +241,7 @@ static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root)
pthread_attr_t t_attr;
struct btrfs_ioctl_send_args io_send;
struct subvol_info *si;
+ struct btrfs_dump dump;
void *t_err = NULL;
int subvol_fd = -1;
int pipefd[2];
@@ -273,10 +274,12 @@ static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root)
io_send.send_fd = pipefd[1];
send->send_fd = pipefd[0];
+ dump.from_fd = pipefd[0];
+ dump.to_fd = send->dump_fd;
if (!ret)
ret = pthread_create(&t_read, &t_attr, dump_thread,
- send);
+ &dump);
if (ret) {
ret = -ret;
fprintf(stderr, "ERROR: thread setup failed: %s\n",
diff --git a/commands.h b/commands.h
index bb6d2dd..c65ba20 100644
--- a/commands.h
+++ b/commands.h
@@ -82,6 +82,14 @@ void help_command_group(const struct cmd_group *grp, int argc, char **argv);
/* common.c */
int open_file_or_dir(const char *fname);
+/* cmds-send.c */
+int write_buf(int fd, const void *buf, int size);
+void * dump_thread(void *arg_);
+struct btrfs_dump {
+ int from_fd;
+ int to_fd;
+};
+
extern const struct cmd_group subvolume_cmd_group;
extern const struct cmd_group filesystem_cmd_group;
extern const struct cmd_group balance_cmd_group;
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] Btrfs-progs: making send.h inline with its kernel side change
2012-09-14 6:04 ` [PATCH] Btrfs-progs: make dump_thread and write_buf usable outside cmds-send.c Anand jain
@ 2012-09-14 6:04 ` Anand jain
2012-09-14 6:04 ` [PATCH] Btrfs: write_buf is now callable outside send.c Anand jain
1 sibling, 0 replies; 11+ messages in thread
From: Anand jain @ 2012-09-14 6:04 UTC (permalink / raw)
To: linux-btrfs; +Cc: chris.mason, hugo
From: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
send.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/send.h b/send.h
index 9934e94..1bf4f32 100644
--- a/send.h
+++ b/send.h
@@ -130,4 +130,5 @@ enum {
#ifdef __KERNEL__
long btrfs_ioctl_send(struct file *mnt_file, void __user *arg);
+int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off);
#endif
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] Btrfs: write_buf is now callable outside send.c
2012-09-14 6:04 ` [PATCH] Btrfs-progs: make dump_thread and write_buf usable outside cmds-send.c Anand jain
2012-09-14 6:04 ` [PATCH] Btrfs-progs: making send.h inline with its kernel side change Anand jain
@ 2012-09-14 6:04 ` Anand jain
1 sibling, 0 replies; 11+ messages in thread
From: Anand jain @ 2012-09-14 6:04 UTC (permalink / raw)
To: linux-btrfs; +Cc: chris.mason, hugo
From: Anand Jain <anand.jain@oracle.com>
Developing service cmds needs it.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/send.c | 11 ++++++-----
fs/btrfs/send.h | 1 +
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index fb5ffe9..89411b3 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -377,7 +377,7 @@ static struct btrfs_path *alloc_path_for_send(void)
return path;
}
-static int write_buf(struct send_ctx *sctx, const void *buf, u32 len)
+int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off)
{
int ret;
mm_segment_t old_fs;
@@ -387,8 +387,7 @@ static int write_buf(struct send_ctx *sctx, const void *buf, u32 len)
set_fs(KERNEL_DS);
while (pos < len) {
- ret = vfs_write(sctx->send_filp, (char *)buf + pos, len - pos,
- &sctx->send_off);
+ ret = vfs_write(filp, (char *)buf + pos, len - pos, off);
/* TODO handle that correctly */
/*if (ret == -ERESTARTSYS) {
continue;
@@ -544,7 +543,8 @@ static int send_header(struct send_ctx *sctx)
strcpy(hdr.magic, BTRFS_SEND_STREAM_MAGIC);
hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION);
- return write_buf(sctx, &hdr, sizeof(hdr));
+ return write_buf(sctx->send_filp, &hdr, sizeof(hdr),
+ &sctx->send_off);
}
/*
@@ -581,7 +581,8 @@ static int send_cmd(struct send_ctx *sctx)
crc = crc32c(0, (unsigned char *)sctx->send_buf, sctx->send_size);
hdr->crc = cpu_to_le32(crc);
- ret = write_buf(sctx, sctx->send_buf, sctx->send_size);
+ ret = write_buf(sctx->send_filp, sctx->send_buf, sctx->send_size,
+ &sctx->send_off);
sctx->total_send_size += sctx->send_size;
sctx->cmd_send_size[le16_to_cpu(hdr->cmd)] += sctx->send_size;
diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h
index 9934e94..1bf4f32 100644
--- a/fs/btrfs/send.h
+++ b/fs/btrfs/send.h
@@ -130,4 +130,5 @@ enum {
#ifdef __KERNEL__
long btrfs_ioctl_send(struct file *mnt_file, void __user *arg);
+int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off);
#endif
--
1.7.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable
2012-09-14 5:50 [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable anand jain
2012-09-14 6:04 ` [PATCH] Btrfs-progs: make dump_thread and write_buf usable outside cmds-send.c Anand jain
@ 2012-09-14 11:04 ` David Sterba
2012-09-17 4:48 ` Anand Jain
1 sibling, 1 reply; 11+ messages in thread
From: David Sterba @ 2012-09-14 11:04 UTC (permalink / raw)
To: anand jain; +Cc: linux-btrfs
On Fri, Sep 14, 2012 at 01:50:24PM +0800, anand jain wrote:
> btrfs send introduced a part of code to read kernel-data
> from user-end using pipe. We need this part of code to be
> useable outside of send sub-cmd, so that developing
> service sub-cmd can use it.
What's 'service sub-cmd' please?
david
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable
2012-09-14 11:04 ` [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable David Sterba
@ 2012-09-17 4:48 ` Anand Jain
2012-09-17 10:28 ` Hugo Mills
2012-09-17 14:59 ` David Sterba
0 siblings, 2 replies; 11+ messages in thread
From: Anand Jain @ 2012-09-17 4:48 UTC (permalink / raw)
To: linux-btrfs
>> btrfs send introduced a part of code to read kernel-data
>> from user-end using pipe. We need this part of code to be
>> useable outside of send sub-cmd, so that developing
>> service sub-cmd can use it.
>
> What's 'service sub-cmd' please?
at the moment 'btrfs service history <mnt>|<dev>'
to show logs of maintenance.
comments/suggestions welcome.
Thanks
-Anand
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable
2012-09-17 4:48 ` Anand Jain
@ 2012-09-17 10:28 ` Hugo Mills
2012-09-18 3:39 ` Anand Jain
2012-09-17 14:59 ` David Sterba
1 sibling, 1 reply; 11+ messages in thread
From: Hugo Mills @ 2012-09-17 10:28 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
[-- Attachment #1: Type: text/plain, Size: 1306 bytes --]
On Mon, Sep 17, 2012 at 12:48:10PM +0800, Anand Jain wrote:
>
> >> btrfs send introduced a part of code to read kernel-data
> >> from user-end using pipe. We need this part of code to be
> >> useable outside of send sub-cmd, so that developing
> >> service sub-cmd can use it.
> >
> >What's 'service sub-cmd' please?
>
> at the moment 'btrfs service history <mnt>|<dev>'
> to show logs of maintenance.
> comments/suggestions welcome.
As I said in our private email exchange some months ago, I don't
think this is the right way to be doing this. For example, if you use
an alternative tool (such as btrfs-gui) which uses the ioctls
directly, you've lost that logging information.
Keeping a log of what's been done to the FS is much better done by
extending the available logging in the kernel (and making it a
compile-time option for those who don't want or need it). You can then
write a simple shell script to chomp through the normal kernel logs to
extract this information.
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
--- I'll take your bet, but make it ten thousand francs. I'm only ---
a _poor_ corrupt official.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable
2012-09-17 4:48 ` Anand Jain
2012-09-17 10:28 ` Hugo Mills
@ 2012-09-17 14:59 ` David Sterba
2012-09-18 5:33 ` Anand Jain
1 sibling, 1 reply; 11+ messages in thread
From: David Sterba @ 2012-09-17 14:59 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Mon, Sep 17, 2012 at 12:48:10PM +0800, Anand Jain wrote:
> >> btrfs send introduced a part of code to read kernel-data
> >> from user-end using pipe. We need this part of code to be
> >> useable outside of send sub-cmd, so that developing
> >> service sub-cmd can use it.
> >
> >What's 'service sub-cmd' please?
>
> at the moment 'btrfs service history <mnt>|<dev>'
> to show logs of maintenance.
> comments/suggestions welcome.
Sorry, but without a more detailed description I can hardly give useful
comments. The patch looks ok but stands alone, you can post it with
your proposed feature together.
david
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable
2012-09-17 10:28 ` Hugo Mills
@ 2012-09-18 3:39 ` Anand Jain
0 siblings, 0 replies; 11+ messages in thread
From: Anand Jain @ 2012-09-18 3:39 UTC (permalink / raw)
To: Hugo Mills, linux-btrfs
> As I said in our private email exchange some months ago, I don't
> think this is the right way to be doing this. For example, if you use
> an alternative tool (such as btrfs-gui) which uses the ioctls
> directly, you've lost that logging information.
I agree with that Hugo. Thanks. These changes are partly for
the same reason.
> Keeping a log of what's been done to the FS is much better done by
> extending the available logging in the kernel
Could you please point out the modules you are talking about.
I reviewed some but just in case if I have missed out any.
Thanks, Anand
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable
2012-09-17 14:59 ` David Sterba
@ 2012-09-18 5:33 ` Anand Jain
2012-09-20 12:34 ` David Sterba
0 siblings, 1 reply; 11+ messages in thread
From: Anand Jain @ 2012-09-18 5:33 UTC (permalink / raw)
To: dave; +Cc: linux-btrfs
>>> What's 'service sub-cmd' please?
>>
>> at the moment 'btrfs service history<mnt>|<dev>'
>> to show logs of maintenance.
>> comments/suggestions welcome.
>
> Sorry, but without a more detailed description I can hardly give useful
> comments.
David,
'btrfs service history <mnt>|<dev>'
is basically to show the list of cli/gui commands which are
successfully run on the btrfs as part of its -
creation (may be), configuration and maintenance.
HTH.
Thanks, Anand
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable
2012-09-18 5:33 ` Anand Jain
@ 2012-09-20 12:34 ` David Sterba
0 siblings, 0 replies; 11+ messages in thread
From: David Sterba @ 2012-09-20 12:34 UTC (permalink / raw)
To: Anand Jain; +Cc: dave, linux-btrfs
On Tue, Sep 18, 2012 at 01:33:29PM +0800, Anand Jain wrote:
> 'btrfs service history <mnt>|<dev>'
> is basically to show the list of cli/gui commands which are
> successfully run on the btrfs as part of its -
> creation (may be), configuration and maintenance.
Is it modelled after ZFS 'zpool history' command? AFAICS it captures
actions modifiying the pools, there's nothing similar for btrfs.
david
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-09-20 12:34 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-14 5:50 [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable anand jain
2012-09-14 6:04 ` [PATCH] Btrfs-progs: make dump_thread and write_buf usable outside cmds-send.c Anand jain
2012-09-14 6:04 ` [PATCH] Btrfs-progs: making send.h inline with its kernel side change Anand jain
2012-09-14 6:04 ` [PATCH] Btrfs: write_buf is now callable outside send.c Anand jain
2012-09-14 11:04 ` [PATCH] Btrfs + Btrfs-progs: make pipe functions re-usable David Sterba
2012-09-17 4:48 ` Anand Jain
2012-09-17 10:28 ` Hugo Mills
2012-09-18 3:39 ` Anand Jain
2012-09-17 14:59 ` David Sterba
2012-09-18 5:33 ` Anand Jain
2012-09-20 12:34 ` 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).