From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9414C2BB86 for ; Tue, 14 Apr 2020 12:44:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7CFB520656 for ; Tue, 14 Apr 2020 12:44:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="afMS7G7p" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CFB520656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2EAB28E000D; Tue, 14 Apr 2020 08:44:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 274BC8E0001; Tue, 14 Apr 2020 08:44:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EE0B8E000D; Tue, 14 Apr 2020 08:44:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id EB3D88E0001 for ; Tue, 14 Apr 2020 08:44:35 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9F7BB181AEF21 for ; Tue, 14 Apr 2020 12:44:35 +0000 (UTC) X-FDA: 76706429310.22.horse43_28099c05cae5e X-HE-Tag: horse43_28099c05cae5e X-Filterd-Recvd-Size: 10464 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 12:44:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586868274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d4V8mrlSuDSVlkahuOUJ4Ixvzo/y3rjT0a9yuAvHerg=; b=afMS7G7pJrStxDVBsjqfIIdyUri5R299a1L4L52AKFaJEM24XoHlMqqG8vRqgeKYUIsWIm +TACeeQ9VahsZLmYGayX4EznzV9AXcOJFqh9hISguE1ySvaPbrBOTbtFnoUF7MjIup5qCZ P239gwimgRsdvzfOLWpyzPRTKD4P48k= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-445-TD7mOLZCMXeFPtMRBwE9Tg-1; Tue, 14 Apr 2020 08:44:33 -0400 X-MC-Unique: TD7mOLZCMXeFPtMRBwE9Tg-1 Received: by mail-wm1-f72.google.com with SMTP id c196so1794681wmd.3 for ; Tue, 14 Apr 2020 05:44:32 -0700 (PDT) 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=HGjNYMWp/8KA/6LkWNSHGIBdRN4UVqzppNqwn3DGPcg=; b=rEfbgnCNW0MwwStwpK8Dm3dsR7HdmZHkA65PbfE0XjNHTynDWwwterxEZ8BXkvr5id gDzdOoZpOTM2FhXIW+SxDv2rMlAv4cPxyNBRfuxxMORgBz0UYrUTSz+DyCDw38QbsL7m OWcwlMsk7+kSDhAbtJDkDp2U6VP3IJMMfUo0FDE2bj5L9SwbXjUuv7f4LxcuOXxLPmTd lhavUIXPEK/BAfQ9HGfGkCcdfqrNUaol1bCimE2tznprQTWr8Ea9MgZdVgmhA/D20afL SH0nQ4Wlcm2TLeTvb1OwdH/IRGjsBl/cUdp8Jn8fhJZAybv6TK8mue+ue7cFqAmWkRn/ tkQg== X-Gm-Message-State: AGi0PuYc25F0TngMDnt4tojGrGNdiQnDzXvLAaF9n/QMDdxJL18t8T9i Q4gvapAaY+DoAl8tRughGdEJ7WvqSlp7MjKHc+rn8sOJNPJH4HdRD4GDU4VfRy3HvLqkNySC589 GH5J8t/AX1Ws= X-Received: by 2002:a1c:4e15:: with SMTP id g21mr5979593wmh.29.1586868271935; Tue, 14 Apr 2020 05:44:31 -0700 (PDT) X-Google-Smtp-Source: APiQypLjQPNPxnNdGqVcxE01hghohpD72CtCG/q4zNp6kiItsyrK+g3gnJAFWjc1kxEekSVDXAwDXg== X-Received: by 2002:a1c:4e15:: with SMTP id g21mr5979510wmh.29.1586868271614; Tue, 14 Apr 2020 05:44:31 -0700 (PDT) Received: from localhost.localdomain ([194.230.155.210]) by smtp.gmail.com with ESMTPSA id m14sm16948816wrs.76.2020.04.14.05.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 05:44:31 -0700 (PDT) From: Emanuele Giuseppe Esposito To: linux-nfs@vger.kernel.org Cc: Paolo Bonzini , Emanuele Giuseppe Esposito , Jeremy Kerr , Arnd Bergmann , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Dennis Dalessandro , Mike Marciniszyn , Doug Ledford , Jason Gunthorpe , Frederic Barrat , Andrew Donnellan , Greg Kroah-Hartman , Robert Richter , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , "James E.J. Bottomley" , "Martin K. Petersen" , Felipe Balbi , Alexander Viro , Ian Kent , Joel Becker , Christoph Hellwig , "Rafael J. Wysocki" , Matthew Garrett , Ard Biesheuvel , Miklos Szeredi , Mike Kravetz , Mark Fasheh , Joseph Qi , Alexey Dobriyan , Luis Chamberlain , Kees Cook , Iurii Zaikin , Anton Vorontsov , Colin Cross , Tony Luck , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Hugh Dickins , Andrew Morton , Trond Myklebust , Anna Schumaker , "J. Bruce Fields" , Chuck Lever , "David S. Miller" , Jakub Kicinski , James Morris , "Serge E. Hallyn" , John Johansen , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, oprofile-list@lists.sf.net, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, linux-fsdevel@vger.kernel.org, autofs@vger.kernel.org, linux-efi@vger.kernel.org, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH 8/8] tracefs: switch to simplefs inode creation API Date: Tue, 14 Apr 2020 14:43:02 +0200 Message-Id: <20200414124304.4470-9-eesposit@redhat.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com> References: <20200414124304.4470-1-eesposit@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: There is no semantic change intended; the code in the simplefs.c functions = in fact was derived from debugfs and tracefs code. Signed-off-by: Emanuele Giuseppe Esposito --- fs/tracefs/inode.c | 86 ++++------------------------------------------ 1 file changed, 7 insertions(+), 79 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index a30837a8e1d4..69e2215c797b 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -298,57 +298,6 @@ static struct file_system_type trace_fs_type =3D { }; MODULE_ALIAS_FS("tracefs"); =20 -static struct dentry *start_creating(const char *name, struct dentry *pare= nt) -{ -=09struct dentry *dentry; -=09int error; - -=09pr_debug("tracefs: creating file '%s'\n",name); - -=09error =3D simple_pin_fs(&tracefs, &trace_fs_type); -=09if (error) -=09=09return ERR_PTR(error); - -=09/* If the parent is not specified, we create it in the root. -=09 * We need the root dentry to do this, which is in the super -=09 * block. A pointer to that is in the struct vfsmount that we -=09 * have around. -=09 */ -=09if (!parent) -=09=09parent =3D tracefs.mount->mnt_root; - -=09inode_lock(parent->d_inode); -=09if (unlikely(IS_DEADDIR(parent->d_inode))) -=09=09dentry =3D ERR_PTR(-ENOENT); -=09else -=09=09dentry =3D lookup_one_len(name, parent, strlen(name)); -=09if (!IS_ERR(dentry) && dentry->d_inode) { -=09=09dput(dentry); -=09=09dentry =3D ERR_PTR(-EEXIST); -=09} - -=09if (IS_ERR(dentry)) { -=09=09inode_unlock(parent->d_inode); -=09=09simple_release_fs(&tracefs); -=09} - -=09return dentry; -} - -static struct dentry *failed_creating(struct dentry *dentry) -{ -=09inode_unlock(dentry->d_parent->d_inode); -=09dput(dentry); -=09simple_release_fs(&tracefs); -=09return NULL; -} - -static struct dentry *end_creating(struct dentry *dentry) -{ -=09inode_unlock(dentry->d_parent->d_inode); -=09return dentry; -} - /** * tracefs_create_file - create a file in the tracefs filesystem * @name: a pointer to a string containing the name of the file to create. @@ -385,49 +334,28 @@ struct dentry *tracefs_create_file(const char *name, = umode_t mode, =09if (security_locked_down(LOCKDOWN_TRACEFS)) =09=09return NULL; =20 -=09if (!(mode & S_IFMT)) -=09=09mode |=3D S_IFREG; -=09BUG_ON(!S_ISREG(mode)); -=09dentry =3D start_creating(name, parent); - +=09dentry =3D simplefs_create_file(&tracefs, &trace_fs_type, +=09=09=09=09 name, mode, parent, data, &inode); =09if (IS_ERR(dentry)) =09=09return NULL; =20 -=09inode =3D simple_new_inode(dentry->d_sb); -=09if (unlikely(!inode)) -=09=09return failed_creating(dentry); - -=09inode->i_mode =3D mode; =09inode->i_fop =3D fops ? fops : &tracefs_file_operations; -=09inode->i_private =3D data; -=09d_instantiate(dentry, inode); -=09fsnotify_create(dentry->d_parent->d_inode, dentry); -=09return end_creating(dentry); +=09return simplefs_finish_dentry(dentry, inode); } =20 static struct dentry *__create_dir(const char *name, struct dentry *parent= , =09=09=09=09 const struct inode_operations *ops) { -=09struct dentry *dentry =3D start_creating(name, parent); +=09struct dentry *dentry; =09struct inode *inode; =20 +=09dentry =3D simplefs_create_dir(&tracefs, &trace_fs_type, +=09=09=09=09 name, 0755, parent, &inode); =09if (IS_ERR(dentry)) =09=09return NULL; =20 -=09inode =3D simple_new_inode(dentry->d_sb); -=09if (unlikely(!inode)) -=09=09return failed_creating(dentry); - -=09inode->i_mode =3D S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; =09inode->i_op =3D ops; -=09inode->i_fop =3D &simple_dir_operations; - -=09/* directory inodes start off with i_nlink =3D=3D 2 (for "." entry) */ -=09inc_nlink(inode); -=09d_instantiate(dentry, inode); -=09inc_nlink(dentry->d_parent->d_inode); -=09fsnotify_mkdir(dentry->d_parent->d_inode, dentry); -=09return end_creating(dentry); +=09return simplefs_finish_dentry(dentry, inode); } =20 /** --=20 2.25.2