[Devel] [PATCH rh7] ploop: push_backup: improve auto destroy
Konstantin Khorenko
khorenko at virtuozzo.com
Fri May 13 09:27:09 PDT 2016
Dropping this patch because if backup tool uses AIO, chances last close() is called from userspace context are really slow =>
let's go in a way when another userspace process (dispatcher?) monitors backup tool state and does appropriate cleanup if needed.
--
Best regards,
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
On 05/12/2016 11:45 PM, Maxim Patlasov wrote:
> When more than one user keeps ploop block device opened, dying backup tool
> doesn't trigger auto destroy.
>
> The patch tries to detect dying backup tool by comparing the pid of
> process starting push_backup with the pid of process closing ploop block
> device.
>
> The patch doesn't ensures auto destroy in 100% cases (firstly because userspace may fork after starting push_backup, and secondly because last __fput may
> happen later, asynchronously from last close(2)), but it must work in most of
> cases.
>
> The patch is based on Dima Monakhov's suggestion. Kudos.
>
> https://jira.sw.ru/browse/PSBM-45000
>
> Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
> ---
> drivers/block/ploop/dev.c | 4 ++++
> drivers/block/ploop/push_backup.c | 11 ++++++++++-
> drivers/block/ploop/push_backup.h | 1 +
> 3 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
> index c103b79..508318e 100644
> --- a/drivers/block/ploop/dev.c
> +++ b/drivers/block/ploop/dev.c
> @@ -2868,6 +2868,10 @@ static void ploop_release(struct gendisk *disk, fmode_t fmode)
> struct ploop_device *plo = disk->private_data;
>
> mutex_lock(&plo->ctl_mutex);
> +
> + if (ploop_pb_get_pid(plo) == current->pid)
> + ploop_pb_destroy(plo, NULL);
> +
> if (atomic_dec_and_test(&plo->open_count)) {
> ploop_pb_destroy(plo, NULL);
> ploop_tracker_stop(plo, 1);
> diff --git a/drivers/block/ploop/push_backup.c b/drivers/block/ploop/push_backup.c
> index 4f23925..c23926d 100644
> --- a/drivers/block/ploop/push_backup.c
> +++ b/drivers/block/ploop/push_backup.c
> @@ -31,9 +31,10 @@ struct ploop_pushbackup_desc {
> struct completion ppb_comp;
> bool ppb_waiting;
>
> -
> struct rb_root pending_tree;
> struct rb_root reported_tree;
> +
> + pid_t ppb_pid; /* who started push_backup */
> };
>
> int ploop_pb_check_uuid(struct ploop_pushbackup_desc *pbd, __u8 *uuid)
> @@ -89,6 +90,7 @@ struct ploop_pushbackup_desc *ploop_pb_alloc(struct ploop_device *plo)
> pbd->pending_tree = RB_ROOT;
> pbd->reported_tree = RB_ROOT;
> pbd->plo = plo;
> + pbd->ppb_pid = current->pid;
>
> return pbd;
> }
> @@ -602,3 +604,10 @@ int ploop_pb_destroy(struct ploop_device *plo, __u32 *status)
>
> return 0;
> }
> +
> +pid_t ploop_pb_get_pid(struct ploop_device *plo)
> +{
> + struct ploop_pushbackup_desc *pbd = plo->pbd;
> +
> + return pbd ? pbd->ppb_pid : -1;
> +}
> diff --git a/drivers/block/ploop/push_backup.h b/drivers/block/ploop/push_backup.h
> index 1a8636a..1a23fd8 100644
> --- a/drivers/block/ploop/push_backup.h
> +++ b/drivers/block/ploop/push_backup.h
> @@ -20,3 +20,4 @@ int ploop_pb_preq_add_pending(struct ploop_pushbackup_desc *pbd,
> struct ploop_request *preq);
>
> int ploop_pb_destroy(struct ploop_device *plo, __u32 *status);
> +pid_t ploop_pb_get_pid(struct ploop_device *plo);
>
> .
>
More information about the Devel
mailing list