Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2585068ybg; Thu, 24 Oct 2019 11:57:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyl519m2C0i3k6fzUMLflcnGKAaCvDLfr7IG28Igy7wgik7D32ROvYnMwIl8Go20ILhxhEl X-Received: by 2002:a17:906:4cd2:: with SMTP id q18mr37079313ejt.319.1571943432471; Thu, 24 Oct 2019 11:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571943432; cv=none; d=google.com; s=arc-20160816; b=fzntnmLfKSYBmHc/yKVItRZXGBOkiUW6cEEMGTz0OGz8/HYPHP1XFqcoj4Rdy6yAtx qjg+pDkhDvQBegL+7UMv1BK4iHmFmn9UPXq7ZEbOPXP3U9q2pOCRn2pwTb00epV0CYR9 G2BTFw6p7lZfZB0FuecyHNBGUauTG7bpr5SzB4Ko+/5cE1C9d4oVpZSc8ex7/a5py5Vp 2cCjeOzJF29J7yUUpW49MXDhXgeKtbQQ0FCA/kPqKaL1llIbPCefS7urizOkc1NG6xEw 6Ft4MMXDkic1hAczzGutX3q4hdouioJFiy2tkw1oUILUGrIu0SJAtlQMVaProkxQMxNl AhcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Kpk3lLUqgGwLu+uXg2SWXaoH3Lz9YjBH7H2wUph1KgI=; b=BW6hcBCgkDP+MBcPhT8cMlnV5Dng05edXzYY4Mcb55mib+YMDusHTdPCECcE4MjsTM 1uIDZgV1HF6NKKFjZkQCzyKco7tWIYdX6BhAgRGmfJ6hPJSI0vS9F00CtviJyO2SnC5u gAkSielnjLnqhuKQGKjsI3QWchvISzBemesW1d5G8clXsgoxT/8csIjigq5rmoTpA1u3 S1Zi+X5TY2pblGQ73UFSemzq8OaUT9DlaD/XwyOq1idZwvQXQC99rjQydMkxoe9Fa4/B NnfX5U9O6OTXQManq7Eoprn9DQ5SIpSfBwZ05nzFIENQm1j0oWu3FOvRew2s7bKguKaO 4fIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nWxtxJU3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h14si5423970ejy.361.2019.10.24.11.56.48; Thu, 24 Oct 2019 11:57:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nWxtxJU3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437110AbfJXCe5 (ORCPT + 99 others); Wed, 23 Oct 2019 22:34:57 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:38468 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408246AbfJXCey (ORCPT ); Wed, 23 Oct 2019 22:34:54 -0400 Received: by mail-qt1-f195.google.com with SMTP id o25so22104606qtr.5; Wed, 23 Oct 2019 19:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kpk3lLUqgGwLu+uXg2SWXaoH3Lz9YjBH7H2wUph1KgI=; b=nWxtxJU3yLMrtDbaMEkPB29QLCMcQtyzX2+hbfzVWMRP3v+2pgmefyckvjP6h5n72d I0PgUVUtiNoIpWg0rO8w8Vxtvwl4aTcTTGf9U7olB8sw05kA78KiHu+dJYCcrsn8kV5g k2GoOT6orFcDnv38hj/dOQPkiS31f4qTF/d3b7RQM0XzIOvvzygynGDAJcQJPLyZMi57 vE0jheD1nyUxdYONNZc5/IZxFVud1ocKSoTZT+fUMu/QtYEAmwR7zkqY9cuR3ek2lQi+ biH1tqQ/UZjQZbuCoeJPj4LR4SSgYJtMXMAYjc5m+n7rREqCUlQmmat5aohDdJEWkq99 ZXzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kpk3lLUqgGwLu+uXg2SWXaoH3Lz9YjBH7H2wUph1KgI=; b=rZUEKQSnDYYIkL62nV3xltuEp3DdgOHuh2HSecpgf5b1yTwO0IJe8uKl16DHiOXdNz 36w3Ufy4wtXR+Qc2GkZzorrOgD7jNfAaCu36+kPI+QsfaV8gKLcOMCWhm8V57XMKwrB6 XUYnkTFc60l77f/FaRKoSpudUrx4mvaxRB9sjTBF+EbdUNY4ymlbY5u2+DbH2QlDbAQx WN/+fSWe2XOfa4JJ7o3Y4gpbm/AKdw3higVE66iQT+OClq9UaHAIyBd6xuqWN/DNrM/t o8bvuAkhMECwZR82M3rcHuvJa968v3vDSjDWi6nQ4875j99M5XBtqhIY/LDyCK9IF3hB 5qYQ== X-Gm-Message-State: APjAAAU6QEX08wUDFsJcuC+xewAr6Je1JMui/MASsU0dV20XPtu/LhBZ K3sKFeHYXHdelWbtBux1SQKobvQH X-Received: by 2002:a05:6214:803:: with SMTP id df3mr12589055qvb.215.1571884492658; Wed, 23 Oct 2019 19:34:52 -0700 (PDT) Received: from localhost.localdomain ([186.212.94.31]) by smtp.gmail.com with ESMTPSA id q16sm10252495qke.22.2019.10.23.19.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 19:34:52 -0700 (PDT) From: Marcos Paulo de Souza To: linux-kernel@vger.kernel.org Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, mpdesouza@suse.com Subject: [PATCH 5/5] btrfs: ioctl: Call btrfs_vol_uevent on subvolume deletion Date: Wed, 23 Oct 2019 23:36:36 -0300 Message-Id: <20191024023636.21124-6-marcos.souza.org@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191024023636.21124-1-marcos.souza.org@gmail.com> References: <20191024023636.21124-1-marcos.souza.org@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marcos Paulo de Souza Since the function btrfs_ioctl_snap_destroy is used for deleting both subvolumes and snapshots it was needed call btrfs_is_snapshot, which checks a giver btrfs_root and returns true if it's a snapshot. The current code is interested in subvolumes only. btrfs_vol_uevent will export two environment variables to udev: BTRFS_VOL_NAME: containing the name of the subvolume deleted BTRFS_VOL_DEL: will signalize that a volume is being deleted One can create a udev rule and check for BTRFS_VOL_DEL being set, these values one could detect whenever a subvolume is deleted, and take any action based on the subvolume name contained in BTRFS_VOL_NAME. Signed-off-by: Marcos Paulo de Souza --- fs/btrfs/ioctl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index c538d3648195..173f2a258508 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2869,6 +2869,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, { struct dentry *parent = file->f_path.dentry; struct btrfs_fs_info *fs_info = btrfs_sb(parent->d_sb); + struct block_device *bdev = fs_info->fs_devices->latest_bdev; struct dentry *dentry; struct inode *dir = d_inode(parent); struct inode *inode; @@ -2962,6 +2963,10 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, err = btrfs_delete_subvolume(dir, dentry); inode_unlock(inode); if (!err) { + /* send uevent only to subvolume deletion */ + if (!btrfs_is_snapshot(dest)) + btrfs_vol_uevent(bdev, false, vol_args->name); + fsnotify_rmdir(dir, dentry); d_delete(dentry); } -- 2.23.0