* [PATCH BUGFIX] block: add missing group association in bio-cloning functions
[not found] <x4960ul7uyw.fsf@segfault.boston.devel.redhat.com>
@ 2016-05-10 20:23 ` Paolo Valente
2016-05-10 20:44 ` Tejun Heo
0 siblings, 1 reply; 18+ messages in thread
From: Paolo Valente @ 2016-05-10 20:23 UTC (permalink / raw)
To: Jens Axboe, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable, Paolo Valente
When a bio is cloned, the newly created bio must be associated with
the same blkcg as the original bio (if BLK_CGROUP is enabled). If
this operation is not performed, then the new bio is not associated
with any group, and the group of the current task is returned when
the group of the bio is requested.
Depending on the cloning frequency, this may cause a large
percentage of the bios belonging to a given group to be treated
as if belonging to other groups (in most cases as if belonging to
the root group). The expected group isolation may thereby be broken.
This commit adds the missing association in bio-cloning functions.
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
---
block/bio.c | 17 +++++++++++++++++
fs/btrfs/extent_io.c | 6 ------
include/linux/bio.h | 2 ++
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 807d25e..e9b136a 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -622,6 +622,8 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs)
}
}
+ bio_clone_blkcg_association(b, bio);
+
return b;
}
EXPORT_SYMBOL(bio_clone_fast);
@@ -695,6 +697,8 @@ integrity_clone:
}
}
+ bio_clone_blkcg_association(bio, bio_src);
+
return bio;
}
EXPORT_SYMBOL(bio_clone_bioset);
@@ -1811,6 +1815,8 @@ struct bio *bio_split(struct bio *bio, int sectors,
bio_advance(bio, split->bi_iter.bi_size);
+ bio_clone_blkcg_association(split, bio);
+
return split;
}
EXPORT_SYMBOL(bio_split);
@@ -2016,6 +2022,17 @@ void bio_disassociate_task(struct bio *bio)
}
}
+/**
+ * bio_clone_blkcg_association - clone blkcg association from src to dst bio
+ * @dst: destination bio
+ * @src: source bio
+ */
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src)
+{
+ if (src->bi_css)
+ WARN_ON(bio_associate_blkcg(dst, src->bi_css));
+}
+
#endif /* CONFIG_BLK_CGROUP */
static void __init biovec_init_slabs(void)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d247fc0..19f6739 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2686,12 +2686,6 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
btrfs_bio->csum = NULL;
btrfs_bio->csum_allocated = NULL;
btrfs_bio->end_io = NULL;
-
-#ifdef CONFIG_BLK_CGROUP
- /* FIXME, put this into bio_clone_bioset */
- if (bio->bi_css)
- bio_associate_blkcg(new, bio->bi_css);
-#endif
}
return new;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 6b7481f..a9ff116 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -527,11 +527,13 @@ extern unsigned int bvec_nr_vecs(unsigned short idx);
int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
int bio_associate_current(struct bio *bio);
void bio_disassociate_task(struct bio *bio);
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
#else /* CONFIG_BLK_CGROUP */
static inline int bio_associate_blkcg(struct bio *bio,
struct cgroup_subsys_state *blkcg_css) { return 0; }
static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
static inline void bio_disassociate_task(struct bio *bio) { }
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src) { return 0; }
#endif /* CONFIG_BLK_CGROUP */
#ifdef CONFIG_HIGHMEM
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX] block: add missing group association in bio-cloning functions
2016-05-10 20:23 ` [PATCH BUGFIX] block: add missing group association in bio-cloning functions Paolo Valente
@ 2016-05-10 20:44 ` Tejun Heo
2016-05-10 21:02 ` [PATCH BUGFIX V2] " Paolo Valente
0 siblings, 1 reply; 18+ messages in thread
From: Tejun Heo @ 2016-05-10 20:44 UTC (permalink / raw)
To: Paolo Valente
Cc: Jens Axboe, linux-block, linux-kernel, ulf.hansson, linus.walleij,
broonie, stable
On Tue, May 10, 2016 at 10:23:41PM +0200, Paolo Valente wrote:
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index 6b7481f..a9ff116 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -527,11 +527,13 @@ extern unsigned int bvec_nr_vecs(unsigned short idx);
> int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
> int bio_associate_current(struct bio *bio);
> void bio_disassociate_task(struct bio *bio);
> +void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
> #else /* CONFIG_BLK_CGROUP */
> static inline int bio_associate_blkcg(struct bio *bio,
> struct cgroup_subsys_state *blkcg_css) { return 0; }
> static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
> static inline void bio_disassociate_task(struct bio *bio) { }
> +void bio_clone_blkcg_association(struct bio *dst, struct bio *src) { return 0; }
^
static inline
--
tejun
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH BUGFIX V2] block: add missing group association in bio-cloning functions
2016-05-10 20:44 ` Tejun Heo
@ 2016-05-10 21:02 ` Paolo Valente
2016-05-10 21:03 ` Tejun Heo
2016-05-10 21:34 ` Jeff Moyer
0 siblings, 2 replies; 18+ messages in thread
From: Paolo Valente @ 2016-05-10 21:02 UTC (permalink / raw)
To: Jens Axboe, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable, Paolo Valente
When a bio is cloned, the newly created bio must be associated with
the same blkcg as the original bio (if BLK_CGROUP is enabled). If
this operation is not performed, then the new bio is not associated
with any group, and the group of the current task is returned when
the group of the bio is requested.
Depending on the cloning frequency, this may cause a large
percentage of the bios belonging to a given group to be treated
as if belonging to other groups (in most cases as if belonging to
the root group). The expected group isolation may thereby be broken.
This commit adds the missing association in bio-cloning functions.
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
---
block/bio.c | 17 +++++++++++++++++
fs/btrfs/extent_io.c | 6 ------
include/linux/bio.h | 3 +++
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 807d25e..e9b136a 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -622,6 +622,8 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs)
}
}
+ bio_clone_blkcg_association(b, bio);
+
return b;
}
EXPORT_SYMBOL(bio_clone_fast);
@@ -695,6 +697,8 @@ integrity_clone:
}
}
+ bio_clone_blkcg_association(bio, bio_src);
+
return bio;
}
EXPORT_SYMBOL(bio_clone_bioset);
@@ -1811,6 +1815,8 @@ struct bio *bio_split(struct bio *bio, int sectors,
bio_advance(bio, split->bi_iter.bi_size);
+ bio_clone_blkcg_association(split, bio);
+
return split;
}
EXPORT_SYMBOL(bio_split);
@@ -2016,6 +2022,17 @@ void bio_disassociate_task(struct bio *bio)
}
}
+/**
+ * bio_clone_blkcg_association - clone blkcg association from src to dst bio
+ * @dst: destination bio
+ * @src: source bio
+ */
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src)
+{
+ if (src->bi_css)
+ WARN_ON(bio_associate_blkcg(dst, src->bi_css));
+}
+
#endif /* CONFIG_BLK_CGROUP */
static void __init biovec_init_slabs(void)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d247fc0..19f6739 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2686,12 +2686,6 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
btrfs_bio->csum = NULL;
btrfs_bio->csum_allocated = NULL;
btrfs_bio->end_io = NULL;
-
-#ifdef CONFIG_BLK_CGROUP
- /* FIXME, put this into bio_clone_bioset */
- if (bio->bi_css)
- bio_associate_blkcg(new, bio->bi_css);
-#endif
}
return new;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 6b7481f..16cbe59 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -527,11 +527,14 @@ extern unsigned int bvec_nr_vecs(unsigned short idx);
int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
int bio_associate_current(struct bio *bio);
void bio_disassociate_task(struct bio *bio);
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
#else /* CONFIG_BLK_CGROUP */
static inline int bio_associate_blkcg(struct bio *bio,
struct cgroup_subsys_state *blkcg_css) { return 0; }
static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
static inline void bio_disassociate_task(struct bio *bio) { }
+static inline void bio_clone_blkcg_association(struct bio *dst,
+ struct bio *src) { return 0; }
#endif /* CONFIG_BLK_CGROUP */
#ifdef CONFIG_HIGHMEM
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V2] block: add missing group association in bio-cloning functions
2016-05-10 21:02 ` [PATCH BUGFIX V2] " Paolo Valente
@ 2016-05-10 21:03 ` Tejun Heo
2016-05-10 21:34 ` Jeff Moyer
1 sibling, 0 replies; 18+ messages in thread
From: Tejun Heo @ 2016-05-10 21:03 UTC (permalink / raw)
To: Paolo Valente
Cc: Jens Axboe, linux-block, linux-kernel, ulf.hansson, linus.walleij,
broonie, stable
On Tue, May 10, 2016 at 11:02:12PM +0200, Paolo Valente wrote:
> When a bio is cloned, the newly created bio must be associated with
> the same blkcg as the original bio (if BLK_CGROUP is enabled). If
> this operation is not performed, then the new bio is not associated
> with any group, and the group of the current task is returned when
> the group of the bio is requested.
>
> Depending on the cloning frequency, this may cause a large
> percentage of the bios belonging to a given group to be treated
> as if belonging to other groups (in most cases as if belonging to
> the root group). The expected group isolation may thereby be broken.
>
> This commit adds the missing association in bio-cloning functions.
>
> Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V2] block: add missing group association in bio-cloning functions
2016-05-10 21:02 ` [PATCH BUGFIX V2] " Paolo Valente
2016-05-10 21:03 ` Tejun Heo
@ 2016-05-10 21:34 ` Jeff Moyer
2016-05-10 21:44 ` Paolo
2016-05-10 22:01 ` [PATCH BUGFIX V3] " Paolo Valente
1 sibling, 2 replies; 18+ messages in thread
From: Jeff Moyer @ 2016-05-10 21:34 UTC (permalink / raw)
To: Paolo Valente
Cc: Jens Axboe, Tejun Heo, linux-block, linux-kernel, ulf.hansson,
linus.walleij, broonie, stable
Paolo Valente <paolo.valente@linaro.org> writes:
> diff --git a/block/bio.c b/block/bio.c
> index 807d25e..e9b136a 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -622,6 +622,8 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs)
> }
> }
>
> + bio_clone_blkcg_association(b, bio);
> +
> return b;
> }
> EXPORT_SYMBOL(bio_clone_fast);
> @@ -695,6 +697,8 @@ integrity_clone:
> }
> }
>
> + bio_clone_blkcg_association(bio, bio_src);
> +
> return bio;
> }
> EXPORT_SYMBOL(bio_clone_bioset);
> @@ -1811,6 +1815,8 @@ struct bio *bio_split(struct bio *bio, int sectors,
>
> bio_advance(bio, split->bi_iter.bi_size);
>
> + bio_clone_blkcg_association(split, bio);
> +
Hi, Paolo,
Did you test this? bio_split calls bio_clone_bioset or bio_clone_fast,
so I'd be surprised if you didn't trigger that newly added warning. :-)
Please remove the bio_split call site.
Cheers,
Jeff
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V2] block: add missing group association in bio-cloning functions
2016-05-10 21:34 ` Jeff Moyer
@ 2016-05-10 21:44 ` Paolo
2016-05-10 22:01 ` [PATCH BUGFIX V3] " Paolo Valente
1 sibling, 0 replies; 18+ messages in thread
From: Paolo @ 2016-05-10 21:44 UTC (permalink / raw)
To: Jeff Moyer
Cc: Jens Axboe, Tejun Heo, linux-block, linux-kernel, ulf.hansson,
linus.walleij, broonie, stable
Il 10/05/2016 23:34, Jeff Moyer ha scritto:
> Paolo Valente <paolo.valente@linaro.org> writes:
>
>> diff --git a/block/bio.c b/block/bio.c
>> index 807d25e..e9b136a 100644
>> --- a/block/bio.c
>> +++ b/block/bio.c
>> @@ -622,6 +622,8 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs)
>> }
>> }
>>
>> + bio_clone_blkcg_association(b, bio);
>> +
>> return b;
>> }
>> EXPORT_SYMBOL(bio_clone_fast);
>> @@ -695,6 +697,8 @@ integrity_clone:
>> }
>> }
>>
>> + bio_clone_blkcg_association(bio, bio_src);
>> +
>> return bio;
>> }
>> EXPORT_SYMBOL(bio_clone_bioset);
>> @@ -1811,6 +1815,8 @@ struct bio *bio_split(struct bio *bio, int sectors,
>>
>> bio_advance(bio, split->bi_iter.bi_size);
>>
>> + bio_clone_blkcg_association(split, bio);
>> +
>
> Hi, Paolo,
>
> Did you test this? bio_split calls bio_clone_bioset or bio_clone_fast,
> so I'd be surprised if you didn't trigger that newly added warning. :-)
Of course I didn't check the kernel log ...
I hope next version will not introduce more bugs than it will fix.
Thanks,
Paolo
> Please remove the bio_split call site.
>
> Cheers,
> Jeff
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH BUGFIX V3] block: add missing group association in bio-cloning functions
2016-05-10 21:34 ` Jeff Moyer
2016-05-10 21:44 ` Paolo
@ 2016-05-10 22:01 ` Paolo Valente
2016-05-11 6:38 ` Nikolay Borisov
1 sibling, 1 reply; 18+ messages in thread
From: Paolo Valente @ 2016-05-10 22:01 UTC (permalink / raw)
To: Jens Axboe, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable, Paolo Valente
When a bio is cloned, the newly created bio must be associated with
the same blkcg as the original bio (if BLK_CGROUP is enabled). If
this operation is not performed, then the new bio is not associated
with any group, and the group of the current task is returned when
the group of the bio is requested.
Depending on the cloning frequency, this may cause a large
percentage of the bios belonging to a given group to be treated
as if belonging to other groups (in most cases as if belonging to
the root group). The expected group isolation may thereby be broken.
This commit adds the missing association in bio-cloning functions.
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
---
block/bio.c | 15 +++++++++++++++
fs/btrfs/extent_io.c | 6 ------
include/linux/bio.h | 3 +++
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 807d25e..5eaf0b5 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -622,6 +622,8 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs)
}
}
+ bio_clone_blkcg_association(b, bio);
+
return b;
}
EXPORT_SYMBOL(bio_clone_fast);
@@ -695,6 +697,8 @@ integrity_clone:
}
}
+ bio_clone_blkcg_association(bio, bio_src);
+
return bio;
}
EXPORT_SYMBOL(bio_clone_bioset);
@@ -2016,6 +2020,17 @@ void bio_disassociate_task(struct bio *bio)
}
}
+/**
+ * bio_clone_blkcg_association - clone blkcg association from src to dst bio
+ * @dst: destination bio
+ * @src: source bio
+ */
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src)
+{
+ if (src->bi_css)
+ WARN_ON(bio_associate_blkcg(dst, src->bi_css));
+}
+
#endif /* CONFIG_BLK_CGROUP */
static void __init biovec_init_slabs(void)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d247fc0..19f6739 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2686,12 +2686,6 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
btrfs_bio->csum = NULL;
btrfs_bio->csum_allocated = NULL;
btrfs_bio->end_io = NULL;
-
-#ifdef CONFIG_BLK_CGROUP
- /* FIXME, put this into bio_clone_bioset */
- if (bio->bi_css)
- bio_associate_blkcg(new, bio->bi_css);
-#endif
}
return new;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 6b7481f..16cbe59 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -527,11 +527,14 @@ extern unsigned int bvec_nr_vecs(unsigned short idx);
int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
int bio_associate_current(struct bio *bio);
void bio_disassociate_task(struct bio *bio);
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
#else /* CONFIG_BLK_CGROUP */
static inline int bio_associate_blkcg(struct bio *bio,
struct cgroup_subsys_state *blkcg_css) { return 0; }
static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
static inline void bio_disassociate_task(struct bio *bio) { }
+static inline void bio_clone_blkcg_association(struct bio *dst,
+ struct bio *src) { return 0; }
#endif /* CONFIG_BLK_CGROUP */
#ifdef CONFIG_HIGHMEM
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V3] block: add missing group association in bio-cloning functions
2016-05-10 22:01 ` [PATCH BUGFIX V3] " Paolo Valente
@ 2016-05-11 6:38 ` Nikolay Borisov
2016-05-11 6:43 ` Nikolay Borisov
0 siblings, 1 reply; 18+ messages in thread
From: Nikolay Borisov @ 2016-05-11 6:38 UTC (permalink / raw)
To: Paolo Valente, Jens Axboe, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable
On 05/11/2016 01:01 AM, Paolo Valente wrote:
> When a bio is cloned, the newly created bio must be associated with
> the same blkcg as the original bio (if BLK_CGROUP is enabled). If
> this operation is not performed, then the new bio is not associated
> with any group, and the group of the current task is returned when
> the group of the bio is requested.
>
> Depending on the cloning frequency, this may cause a large
> percentage of the bios belonging to a given group to be treated
> as if belonging to other groups (in most cases as if belonging to
> the root group). The expected group isolation may thereby be broken.
>
> This commit adds the missing association in bio-cloning functions.
>
> Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
> ---
> block/bio.c | 15 +++++++++++++++
> fs/btrfs/extent_io.c | 6 ------
> include/linux/bio.h | 3 +++
> 3 files changed, 18 insertions(+), 6 deletions(-)
>
Just for reference something like that was already proposed (and tested)
before, though it never got merged :
https://www.redhat.com/archives/dm-devel/2016-March/msg00007.html
So you might also want to patch __bio_clone_fast to also apply this for
dm backed devices.
Otherwise:
Reviewed-by: Nikolay Borisov <kernel@kyup.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V3] block: add missing group association in bio-cloning functions
2016-05-11 6:38 ` Nikolay Borisov
@ 2016-05-11 6:43 ` Nikolay Borisov
2016-05-11 9:06 ` Paolo
2016-05-11 9:28 ` [PATCH BUGFIX V4] " Paolo Valente
0 siblings, 2 replies; 18+ messages in thread
From: Nikolay Borisov @ 2016-05-11 6:43 UTC (permalink / raw)
To: Paolo Valente, Jens Axboe, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable
On 05/11/2016 09:38 AM, Nikolay Borisov wrote:
>
>
> On 05/11/2016 01:01 AM, Paolo Valente wrote:
>> When a bio is cloned, the newly created bio must be associated with
>> the same blkcg as the original bio (if BLK_CGROUP is enabled). If
>> this operation is not performed, then the new bio is not associated
>> with any group, and the group of the current task is returned when
>> the group of the bio is requested.
>>
>> Depending on the cloning frequency, this may cause a large
>> percentage of the bios belonging to a given group to be treated
>> as if belonging to other groups (in most cases as if belonging to
>> the root group). The expected group isolation may thereby be broken.
>>
>> This commit adds the missing association in bio-cloning functions.
>>
>> Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
>> ---
>> block/bio.c | 15 +++++++++++++++
>> fs/btrfs/extent_io.c | 6 ------
>> include/linux/bio.h | 3 +++
>> 3 files changed, 18 insertions(+), 6 deletions(-)
>>
>
> Just for reference something like that was already proposed (and tested)
> before, though it never got merged :
>
> https://www.redhat.com/archives/dm-devel/2016-March/msg00007.html
>
> So you might also want to patch __bio_clone_fast to also apply this for
> dm backed devices.
Right, to correct myself: You might want to move the association to
__blk_clone_fast that way you are also covering dm devices as well as
users of bio_clone_fast.
>
> Otherwise:
>
> Reviewed-by: Nikolay Borisov <kernel@kyup.com>
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V3] block: add missing group association in bio-cloning functions
2016-05-11 6:43 ` Nikolay Borisov
@ 2016-05-11 9:06 ` Paolo
2016-05-11 9:28 ` [PATCH BUGFIX V4] " Paolo Valente
1 sibling, 0 replies; 18+ messages in thread
From: Paolo @ 2016-05-11 9:06 UTC (permalink / raw)
To: Nikolay Borisov, Jens Axboe, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable
Il 11/05/2016 08:43, Nikolay Borisov ha scritto:
>
>
> On 05/11/2016 09:38 AM, Nikolay Borisov wrote:
>>
>>
>> On 05/11/2016 01:01 AM, Paolo Valente wrote:
>>> When a bio is cloned, the newly created bio must be associated with
>>> the same blkcg as the original bio (if BLK_CGROUP is enabled). If
>>> this operation is not performed, then the new bio is not associated
>>> with any group, and the group of the current task is returned when
>>> the group of the bio is requested.
>>>
>>> Depending on the cloning frequency, this may cause a large
>>> percentage of the bios belonging to a given group to be treated
>>> as if belonging to other groups (in most cases as if belonging to
>>> the root group). The expected group isolation may thereby be broken.
>>>
>>> This commit adds the missing association in bio-cloning functions.
>>>
>>> Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
>>> ---
>>> block/bio.c | 15 +++++++++++++++
>>> fs/btrfs/extent_io.c | 6 ------
>>> include/linux/bio.h | 3 +++
>>> 3 files changed, 18 insertions(+), 6 deletions(-)
>>>
>>
>> Just for reference something like that was already proposed (and tested)
>> before, though it never got merged :
>>
>> https://www.redhat.com/archives/dm-devel/2016-March/msg00007.html
>>
>> So you might also want to patch __bio_clone_fast to also apply this for
>> dm backed devices.
>
> Right, to correct myself: You might want to move the association to
> __blk_clone_fast that way you are also covering dm devices as well as
> users of bio_clone_fast.
>
Definitely (I didn't do that in the first place, because I worried
only about doing the association when bio_clone_fast was certainly
successful).
I'm sending a fresh patch.
Thanks,
Paolo
>
>>
>> Otherwise:
>>
>> Reviewed-by: Nikolay Borisov <kernel@kyup.com>
>>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH BUGFIX V4] block: add missing group association in bio-cloning functions
2016-05-11 6:43 ` Nikolay Borisov
2016-05-11 9:06 ` Paolo
@ 2016-05-11 9:28 ` Paolo Valente
2016-05-12 15:10 ` Tejun Heo
2016-05-13 20:42 ` Jeff Moyer
1 sibling, 2 replies; 18+ messages in thread
From: Paolo Valente @ 2016-05-11 9:28 UTC (permalink / raw)
To: Jens Axboe, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable, Paolo Valente
When a bio is cloned, the newly created bio must be associated with
the same blkcg as the original bio (if BLK_CGROUP is enabled). If
this operation is not performed, then the new bio is not associated
with any group, and the group of the current task is returned when
the group of the bio is requested.
Depending on the cloning frequency, this may cause a large
percentage of the bios belonging to a given group to be treated
as if belonging to other groups (in most cases as if belonging to
the root group). The expected group isolation may thereby be broken.
This commit adds the missing association in bio-cloning functions.
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
Reviewed-by: Nikolay Borisov <kernel@kyup.com>
---
Tejun: I didn't add also your Ack, just because this version is slightly
different from the one you acked.
---
block/bio.c | 15 +++++++++++++++
fs/btrfs/extent_io.c | 6 ------
include/linux/bio.h | 3 +++
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 807d25e..89f517c 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -590,6 +590,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
bio->bi_rw = bio_src->bi_rw;
bio->bi_iter = bio_src->bi_iter;
bio->bi_io_vec = bio_src->bi_io_vec;
+
+ bio_clone_blkcg_association(bio, bio_src);
}
EXPORT_SYMBOL(__bio_clone_fast);
@@ -695,6 +697,8 @@ integrity_clone:
}
}
+ bio_clone_blkcg_association(bio, bio_src);
+
return bio;
}
EXPORT_SYMBOL(bio_clone_bioset);
@@ -2016,6 +2020,17 @@ void bio_disassociate_task(struct bio *bio)
}
}
+/**
+ * bio_clone_blkcg_association - clone blkcg association from src to dst bio
+ * @dst: destination bio
+ * @src: source bio
+ */
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src)
+{
+ if (src->bi_css)
+ WARN_ON(bio_associate_blkcg(dst, src->bi_css));
+}
+
#endif /* CONFIG_BLK_CGROUP */
static void __init biovec_init_slabs(void)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d247fc0..19f6739 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2686,12 +2686,6 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
btrfs_bio->csum = NULL;
btrfs_bio->csum_allocated = NULL;
btrfs_bio->end_io = NULL;
-
-#ifdef CONFIG_BLK_CGROUP
- /* FIXME, put this into bio_clone_bioset */
- if (bio->bi_css)
- bio_associate_blkcg(new, bio->bi_css);
-#endif
}
return new;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 6b7481f..16cbe59 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -527,11 +527,14 @@ extern unsigned int bvec_nr_vecs(unsigned short idx);
int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
int bio_associate_current(struct bio *bio);
void bio_disassociate_task(struct bio *bio);
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
#else /* CONFIG_BLK_CGROUP */
static inline int bio_associate_blkcg(struct bio *bio,
struct cgroup_subsys_state *blkcg_css) { return 0; }
static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
static inline void bio_disassociate_task(struct bio *bio) { }
+static inline void bio_clone_blkcg_association(struct bio *dst,
+ struct bio *src) { return 0; }
#endif /* CONFIG_BLK_CGROUP */
#ifdef CONFIG_HIGHMEM
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V4] block: add missing group association in bio-cloning functions
2016-05-11 9:28 ` [PATCH BUGFIX V4] " Paolo Valente
@ 2016-05-12 15:10 ` Tejun Heo
2016-05-13 20:42 ` Jeff Moyer
1 sibling, 0 replies; 18+ messages in thread
From: Tejun Heo @ 2016-05-12 15:10 UTC (permalink / raw)
To: Paolo Valente
Cc: Jens Axboe, linux-block, linux-kernel, ulf.hansson, linus.walleij,
broonie, stable
On Wed, May 11, 2016 at 11:28:04AM +0200, Paolo Valente wrote:
> When a bio is cloned, the newly created bio must be associated with
> the same blkcg as the original bio (if BLK_CGROUP is enabled). If
> this operation is not performed, then the new bio is not associated
> with any group, and the group of the current task is returned when
> the group of the bio is requested.
>
> Depending on the cloning frequency, this may cause a large
> percentage of the bios belonging to a given group to be treated
> as if belonging to other groups (in most cases as if belonging to
> the root group). The expected group isolation may thereby be broken.
>
> This commit adds the missing association in bio-cloning functions.
>
> Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
> Reviewed-by: Nikolay Borisov <kernel@kyup.com>
Acked-by: Tejun Heo <tj@kernel.org>
It prolly should also have the following tags
Fixes: da2f0f74cf7d ("Btrfs: add support for blkio controllers")
Cc: stable@vger.kernel.org # v4.3+
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V4] block: add missing group association in bio-cloning functions
2016-05-11 9:28 ` [PATCH BUGFIX V4] " Paolo Valente
2016-05-12 15:10 ` Tejun Heo
@ 2016-05-13 20:42 ` Jeff Moyer
2016-06-07 7:09 ` Paolo
2016-07-26 16:14 ` Paolo Valente
1 sibling, 2 replies; 18+ messages in thread
From: Jeff Moyer @ 2016-05-13 20:42 UTC (permalink / raw)
To: Paolo Valente
Cc: Jens Axboe, Tejun Heo, linux-block, linux-kernel, ulf.hansson,
linus.walleij, broonie, stable
Paolo Valente <paolo.valente@linaro.org> writes:
> When a bio is cloned, the newly created bio must be associated with
> the same blkcg as the original bio (if BLK_CGROUP is enabled). If
> this operation is not performed, then the new bio is not associated
> with any group, and the group of the current task is returned when
> the group of the bio is requested.
>
> Depending on the cloning frequency, this may cause a large
> percentage of the bios belonging to a given group to be treated
> as if belonging to other groups (in most cases as if belonging to
> the root group). The expected group isolation may thereby be broken.
>
> This commit adds the missing association in bio-cloning functions.
>
> Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
> Reviewed-by: Nikolay Borisov <kernel@kyup.com>
I think this one's golden! Thanks, Paolo!
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
> ---
> Tejun: I didn't add also your Ack, just because this version is slightly
> different from the one you acked.
> ---
> block/bio.c | 15 +++++++++++++++
> fs/btrfs/extent_io.c | 6 ------
> include/linux/bio.h | 3 +++
> 3 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/block/bio.c b/block/bio.c
> index 807d25e..89f517c 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -590,6 +590,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
> bio->bi_rw = bio_src->bi_rw;
> bio->bi_iter = bio_src->bi_iter;
> bio->bi_io_vec = bio_src->bi_io_vec;
> +
> + bio_clone_blkcg_association(bio, bio_src);
> }
> EXPORT_SYMBOL(__bio_clone_fast);
>
> @@ -695,6 +697,8 @@ integrity_clone:
> }
> }
>
> + bio_clone_blkcg_association(bio, bio_src);
> +
> return bio;
> }
> EXPORT_SYMBOL(bio_clone_bioset);
> @@ -2016,6 +2020,17 @@ void bio_disassociate_task(struct bio *bio)
> }
> }
>
> +/**
> + * bio_clone_blkcg_association - clone blkcg association from src to dst bio
> + * @dst: destination bio
> + * @src: source bio
> + */
> +void bio_clone_blkcg_association(struct bio *dst, struct bio *src)
> +{
> + if (src->bi_css)
> + WARN_ON(bio_associate_blkcg(dst, src->bi_css));
> +}
> +
> #endif /* CONFIG_BLK_CGROUP */
>
> static void __init biovec_init_slabs(void)
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index d247fc0..19f6739 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -2686,12 +2686,6 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
> btrfs_bio->csum = NULL;
> btrfs_bio->csum_allocated = NULL;
> btrfs_bio->end_io = NULL;
> -
> -#ifdef CONFIG_BLK_CGROUP
> - /* FIXME, put this into bio_clone_bioset */
> - if (bio->bi_css)
> - bio_associate_blkcg(new, bio->bi_css);
> -#endif
> }
> return new;
> }
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index 6b7481f..16cbe59 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -527,11 +527,14 @@ extern unsigned int bvec_nr_vecs(unsigned short idx);
> int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
> int bio_associate_current(struct bio *bio);
> void bio_disassociate_task(struct bio *bio);
> +void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
> #else /* CONFIG_BLK_CGROUP */
> static inline int bio_associate_blkcg(struct bio *bio,
> struct cgroup_subsys_state *blkcg_css) { return 0; }
> static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
> static inline void bio_disassociate_task(struct bio *bio) { }
> +static inline void bio_clone_blkcg_association(struct bio *dst,
> + struct bio *src) { return 0; }
> #endif /* CONFIG_BLK_CGROUP */
>
> #ifdef CONFIG_HIGHMEM
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V4] block: add missing group association in bio-cloning functions
2016-05-13 20:42 ` Jeff Moyer
@ 2016-06-07 7:09 ` Paolo
2016-07-26 16:14 ` Paolo Valente
1 sibling, 0 replies; 18+ messages in thread
From: Paolo @ 2016-06-07 7:09 UTC (permalink / raw)
To: Jeff Moyer
Cc: Jens Axboe, Tejun Heo, linux-block, linux-kernel, ulf.hansson,
linus.walleij, broonie, stable
Jens,
are you picking this fix?
Thanks,
Paolo
Il 13/05/2016 22:42, Jeff Moyer ha scritto:
> Paolo Valente <paolo.valente@linaro.org> writes:
>
>> When a bio is cloned, the newly created bio must be associated with
>> the same blkcg as the original bio (if BLK_CGROUP is enabled). If
>> this operation is not performed, then the new bio is not associated
>> with any group, and the group of the current task is returned when
>> the group of the bio is requested.
>>
>> Depending on the cloning frequency, this may cause a large
>> percentage of the bios belonging to a given group to be treated
>> as if belonging to other groups (in most cases as if belonging to
>> the root group). The expected group isolation may thereby be broken.
>>
>> This commit adds the missing association in bio-cloning functions.
>>
>> Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
>> Reviewed-by: Nikolay Borisov <kernel@kyup.com>
>
> I think this one's golden! Thanks, Paolo!
>
> Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
>
>
>> ---
>> Tejun: I didn't add also your Ack, just because this version is slightly
>> different from the one you acked.
>> ---
>> block/bio.c | 15 +++++++++++++++
>> fs/btrfs/extent_io.c | 6 ------
>> include/linux/bio.h | 3 +++
>> 3 files changed, 18 insertions(+), 6 deletions(-)
>>
>> diff --git a/block/bio.c b/block/bio.c
>> index 807d25e..89f517c 100644
>> --- a/block/bio.c
>> +++ b/block/bio.c
>> @@ -590,6 +590,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
>> bio->bi_rw = bio_src->bi_rw;
>> bio->bi_iter = bio_src->bi_iter;
>> bio->bi_io_vec = bio_src->bi_io_vec;
>> +
>> + bio_clone_blkcg_association(bio, bio_src);
>> }
>> EXPORT_SYMBOL(__bio_clone_fast);
>>
>> @@ -695,6 +697,8 @@ integrity_clone:
>> }
>> }
>>
>> + bio_clone_blkcg_association(bio, bio_src);
>> +
>> return bio;
>> }
>> EXPORT_SYMBOL(bio_clone_bioset);
>> @@ -2016,6 +2020,17 @@ void bio_disassociate_task(struct bio *bio)
>> }
>> }
>>
>> +/**
>> + * bio_clone_blkcg_association - clone blkcg association from src to dst bio
>> + * @dst: destination bio
>> + * @src: source bio
>> + */
>> +void bio_clone_blkcg_association(struct bio *dst, struct bio *src)
>> +{
>> + if (src->bi_css)
>> + WARN_ON(bio_associate_blkcg(dst, src->bi_css));
>> +}
>> +
>> #endif /* CONFIG_BLK_CGROUP */
>>
>> static void __init biovec_init_slabs(void)
>> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
>> index d247fc0..19f6739 100644
>> --- a/fs/btrfs/extent_io.c
>> +++ b/fs/btrfs/extent_io.c
>> @@ -2686,12 +2686,6 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
>> btrfs_bio->csum = NULL;
>> btrfs_bio->csum_allocated = NULL;
>> btrfs_bio->end_io = NULL;
>> -
>> -#ifdef CONFIG_BLK_CGROUP
>> - /* FIXME, put this into bio_clone_bioset */
>> - if (bio->bi_css)
>> - bio_associate_blkcg(new, bio->bi_css);
>> -#endif
>> }
>> return new;
>> }
>> diff --git a/include/linux/bio.h b/include/linux/bio.h
>> index 6b7481f..16cbe59 100644
>> --- a/include/linux/bio.h
>> +++ b/include/linux/bio.h
>> @@ -527,11 +527,14 @@ extern unsigned int bvec_nr_vecs(unsigned short idx);
>> int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
>> int bio_associate_current(struct bio *bio);
>> void bio_disassociate_task(struct bio *bio);
>> +void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
>> #else /* CONFIG_BLK_CGROUP */
>> static inline int bio_associate_blkcg(struct bio *bio,
>> struct cgroup_subsys_state *blkcg_css) { return 0; }
>> static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
>> static inline void bio_disassociate_task(struct bio *bio) { }
>> +static inline void bio_clone_blkcg_association(struct bio *dst,
>> + struct bio *src) { return 0; }
>> #endif /* CONFIG_BLK_CGROUP */
>>
>> #ifdef CONFIG_HIGHMEM
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH BUGFIX V4] block: add missing group association in bio-cloning functions
2016-05-13 20:42 ` Jeff Moyer
2016-06-07 7:09 ` Paolo
@ 2016-07-26 16:14 ` Paolo Valente
2016-07-26 17:01 ` kbuild test robot
2016-07-27 5:22 ` [PATCH BUGFIX V5] " Paolo Valente
1 sibling, 2 replies; 18+ messages in thread
From: Paolo Valente @ 2016-07-26 16:14 UTC (permalink / raw)
To: Jens Axboe, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable, jmoyer, Nikolay Borisov, Paolo Valente
When a bio is cloned, the newly created bio must be associated with
the same blkcg as the original bio (if BLK_CGROUP is enabled). If
this operation is not performed, then the new bio is not associated
with any group, and the group of the current task is returned when
the group of the bio is requested.
Depending on the cloning frequency, this may cause a large
percentage of the bios belonging to a given group to be treated
as if belonging to other groups (in most cases as if belonging to
the root group). The expected group isolation may thereby be broken.
This commit adds the missing association in bio-cloning functions.
Fixes: da2f0f74cf7d ("Btrfs: add support for blkio controllers")
Cc: stable@vger.kernel.org # v4.3+
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
Reviewed-by: Nikolay Borisov <kernel@kyup.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
block/bio.c | 15 +++++++++++++++
fs/btrfs/extent_io.c | 6 ------
include/linux/bio.h | 3 +++
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 0e4aa42..4623869 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -579,6 +579,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
bio->bi_rw = bio_src->bi_rw;
bio->bi_iter = bio_src->bi_iter;
bio->bi_io_vec = bio_src->bi_io_vec;
+
+ bio_clone_blkcg_association(bio, bio_src);
}
EXPORT_SYMBOL(__bio_clone_fast);
@@ -684,6 +686,8 @@ integrity_clone:
}
}
+ bio_clone_blkcg_association(bio, bio_src);
+
return bio;
}
EXPORT_SYMBOL(bio_clone_bioset);
@@ -2005,6 +2009,17 @@ void bio_disassociate_task(struct bio *bio)
}
}
+/**
+ * bio_clone_blkcg_association - clone blkcg association from src to dst bio
+ * @dst: destination bio
+ * @src: source bio
+ */
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src)
+{
+ if (src->bi_css)
+ WARN_ON(bio_associate_blkcg(dst, src->bi_css));
+}
+
#endif /* CONFIG_BLK_CGROUP */
static void __init biovec_init_slabs(void)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 75533ad..92fe3f8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2696,12 +2696,6 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
btrfs_bio->csum = NULL;
btrfs_bio->csum_allocated = NULL;
btrfs_bio->end_io = NULL;
-
-#ifdef CONFIG_BLK_CGROUP
- /* FIXME, put this into bio_clone_bioset */
- if (bio->bi_css)
- bio_associate_blkcg(new, bio->bi_css);
-#endif
}
return new;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 9faebf7..c9403b7 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -527,11 +527,14 @@ extern unsigned int bvec_nr_vecs(unsigned short idx);
int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
int bio_associate_current(struct bio *bio);
void bio_disassociate_task(struct bio *bio);
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
#else /* CONFIG_BLK_CGROUP */
static inline int bio_associate_blkcg(struct bio *bio,
struct cgroup_subsys_state *blkcg_css) { return 0; }
static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
static inline void bio_disassociate_task(struct bio *bio) { }
+static inline void bio_clone_blkcg_association(struct bio *dst,
+ struct bio *src) { return 0; }
#endif /* CONFIG_BLK_CGROUP */
#ifdef CONFIG_HIGHMEM
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V4] block: add missing group association in bio-cloning functions
2016-07-26 16:14 ` Paolo Valente
@ 2016-07-26 17:01 ` kbuild test robot
2016-07-27 5:22 ` [PATCH BUGFIX V5] " Paolo Valente
1 sibling, 0 replies; 18+ messages in thread
From: kbuild test robot @ 2016-07-26 17:01 UTC (permalink / raw)
To: Paolo Valente
Cc: kbuild-all, Jens Axboe, Tejun Heo, linux-block, linux-kernel,
ulf.hansson, linus.walleij, broonie, stable, jmoyer,
Nikolay Borisov, Paolo Valente
[-- Attachment #1: Type: text/plain, Size: 2594 bytes --]
Hi,
[auto build test WARNING on block/for-next]
[also build test WARNING on v4.7 next-20160726]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Paolo-Valente/block-add-missing-group-association-in-bio-cloning-functions/20160727-005044
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
config: x86_64-randconfig-x015-201630 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
In file included from block/bio.c:20:0:
include/linux/bio.h: In function 'bio_clone_blkcg_association':
>> include/linux/bio.h:480:30: warning: 'return' with a value, in function returning void
struct bio *src) { return 0; }
^
include/linux/bio.h:479:20: note: declared here
static inline void bio_clone_blkcg_association(struct bio *dst,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/return +480 include/linux/bio.h
464 void zero_fill_bio(struct bio *bio);
465 extern struct bio_vec *bvec_alloc(gfp_t, int, unsigned long *, mempool_t *);
466 extern void bvec_free(mempool_t *, struct bio_vec *, unsigned int);
467 extern unsigned int bvec_nr_vecs(unsigned short idx);
468
469 #ifdef CONFIG_BLK_CGROUP
470 int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
471 int bio_associate_current(struct bio *bio);
472 void bio_disassociate_task(struct bio *bio);
473 void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
474 #else /* CONFIG_BLK_CGROUP */
475 static inline int bio_associate_blkcg(struct bio *bio,
476 struct cgroup_subsys_state *blkcg_css) { return 0; }
477 static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
478 static inline void bio_disassociate_task(struct bio *bio) { }
479 static inline void bio_clone_blkcg_association(struct bio *dst,
> 480 struct bio *src) { return 0; }
481 #endif /* CONFIG_BLK_CGROUP */
482
483 #ifdef CONFIG_HIGHMEM
484 /*
485 * remember never ever reenable interrupts between a bvec_kmap_irq and
486 * bvec_kunmap_irq!
487 */
488 static inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags)
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 26155 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH BUGFIX V5] block: add missing group association in bio-cloning functions
2016-07-26 16:14 ` Paolo Valente
2016-07-26 17:01 ` kbuild test robot
@ 2016-07-27 5:22 ` Paolo Valente
2016-07-27 14:45 ` Jens Axboe
1 sibling, 1 reply; 18+ messages in thread
From: Paolo Valente @ 2016-07-27 5:22 UTC (permalink / raw)
To: Jens Axboe, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable, jmoyer, Nikolay Borisov, Paolo Valente
When a bio is cloned, the newly created bio must be associated with
the same blkcg as the original bio (if BLK_CGROUP is enabled). If
this operation is not performed, then the new bio is not associated
with any group, and the group of the current task is returned when
the group of the bio is requested.
Depending on the cloning frequency, this may cause a large
percentage of the bios belonging to a given group to be treated
as if belonging to other groups (in most cases as if belonging to
the root group). The expected group isolation may thereby be broken.
This commit adds the missing association in bio-cloning functions.
Fixes: da2f0f74cf7d ("Btrfs: add support for blkio controllers")
Cc: stable@vger.kernel.org # v4.3+
Signed-off-by: Paolo Valente <paolo.valente@linaro.org>
Reviewed-by: Nikolay Borisov <kernel@kyup.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
Fixed a compilation issue reported by kbuild test robot
---
block/bio.c | 15 +++++++++++++++
fs/btrfs/extent_io.c | 6 ------
include/linux/bio.h | 3 +++
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 0e4aa42..4623869 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -579,6 +579,8 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
bio->bi_rw = bio_src->bi_rw;
bio->bi_iter = bio_src->bi_iter;
bio->bi_io_vec = bio_src->bi_io_vec;
+
+ bio_clone_blkcg_association(bio, bio_src);
}
EXPORT_SYMBOL(__bio_clone_fast);
@@ -684,6 +686,8 @@ integrity_clone:
}
}
+ bio_clone_blkcg_association(bio, bio_src);
+
return bio;
}
EXPORT_SYMBOL(bio_clone_bioset);
@@ -2005,6 +2009,17 @@ void bio_disassociate_task(struct bio *bio)
}
}
+/**
+ * bio_clone_blkcg_association - clone blkcg association from src to dst bio
+ * @dst: destination bio
+ * @src: source bio
+ */
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src)
+{
+ if (src->bi_css)
+ WARN_ON(bio_associate_blkcg(dst, src->bi_css));
+}
+
#endif /* CONFIG_BLK_CGROUP */
static void __init biovec_init_slabs(void)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 75533ad..92fe3f8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2696,12 +2696,6 @@ struct bio *btrfs_bio_clone(struct bio *bio, gfp_t gfp_mask)
btrfs_bio->csum = NULL;
btrfs_bio->csum_allocated = NULL;
btrfs_bio->end_io = NULL;
-
-#ifdef CONFIG_BLK_CGROUP
- /* FIXME, put this into bio_clone_bioset */
- if (bio->bi_css)
- bio_associate_blkcg(new, bio->bi_css);
-#endif
}
return new;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 9faebf7..75fadd2 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -527,11 +527,14 @@ extern unsigned int bvec_nr_vecs(unsigned short idx);
int bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css);
int bio_associate_current(struct bio *bio);
void bio_disassociate_task(struct bio *bio);
+void bio_clone_blkcg_association(struct bio *dst, struct bio *src);
#else /* CONFIG_BLK_CGROUP */
static inline int bio_associate_blkcg(struct bio *bio,
struct cgroup_subsys_state *blkcg_css) { return 0; }
static inline int bio_associate_current(struct bio *bio) { return -ENOENT; }
static inline void bio_disassociate_task(struct bio *bio) { }
+static inline void bio_clone_blkcg_association(struct bio *dst,
+ struct bio *src) { }
#endif /* CONFIG_BLK_CGROUP */
#ifdef CONFIG_HIGHMEM
--
1.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH BUGFIX V5] block: add missing group association in bio-cloning functions
2016-07-27 5:22 ` [PATCH BUGFIX V5] " Paolo Valente
@ 2016-07-27 14:45 ` Jens Axboe
0 siblings, 0 replies; 18+ messages in thread
From: Jens Axboe @ 2016-07-27 14:45 UTC (permalink / raw)
To: Paolo Valente, Tejun Heo
Cc: linux-block, linux-kernel, ulf.hansson, linus.walleij, broonie,
stable, jmoyer, Nikolay Borisov
On 07/26/2016 11:22 PM, Paolo Valente wrote:
> When a bio is cloned, the newly created bio must be associated with
> the same blkcg as the original bio (if BLK_CGROUP is enabled). If
> this operation is not performed, then the new bio is not associated
> with any group, and the group of the current task is returned when
> the group of the bio is requested.
>
> Depending on the cloning frequency, this may cause a large
> percentage of the bios belonging to a given group to be treated
> as if belonging to other groups (in most cases as if belonging to
> the root group). The expected group isolation may thereby be broken.
>
> This commit adds the missing association in bio-cloning functions.
Added for 4.8, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2016-07-27 14:45 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <x4960ul7uyw.fsf@segfault.boston.devel.redhat.com>
2016-05-10 20:23 ` [PATCH BUGFIX] block: add missing group association in bio-cloning functions Paolo Valente
2016-05-10 20:44 ` Tejun Heo
2016-05-10 21:02 ` [PATCH BUGFIX V2] " Paolo Valente
2016-05-10 21:03 ` Tejun Heo
2016-05-10 21:34 ` Jeff Moyer
2016-05-10 21:44 ` Paolo
2016-05-10 22:01 ` [PATCH BUGFIX V3] " Paolo Valente
2016-05-11 6:38 ` Nikolay Borisov
2016-05-11 6:43 ` Nikolay Borisov
2016-05-11 9:06 ` Paolo
2016-05-11 9:28 ` [PATCH BUGFIX V4] " Paolo Valente
2016-05-12 15:10 ` Tejun Heo
2016-05-13 20:42 ` Jeff Moyer
2016-06-07 7:09 ` Paolo
2016-07-26 16:14 ` Paolo Valente
2016-07-26 17:01 ` kbuild test robot
2016-07-27 5:22 ` [PATCH BUGFIX V5] " Paolo Valente
2016-07-27 14:45 ` Jens Axboe
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).