From patchwork Thu Jan 18 14:46:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 189238 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp389775dyb; Thu, 18 Jan 2024 06:48:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEoYvm+cJJ61zhjveF6hfWb4pW60xylGRHSqf3heHUMvoG5uM81YzYIN68P49KgvOW28QB X-Received: by 2002:a05:6359:620a:b0:175:75a2:62a2 with SMTP id sc10-20020a056359620a00b0017575a262a2mr506905rwb.46.1705589338512; Thu, 18 Jan 2024 06:48:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705589338; cv=pass; d=google.com; s=arc-20160816; b=uEvHP3fY3ycB49xkXPsVV09wbOxsrJV0jo9GepDAu4cy8fUx/qgCE3El3ucyjCVPDX 2XEABBN8A0KclPfaBU45wiwj+GF3Exgsk8Hb33kppVtLSOYFeD3Jj28lrDqrfZ/fZZbj I9ZBoTU+viI3jCG575wxBOENuOh36BSUdERYmDduFHD30xMpwpDkbg9LacfCQajctlWn mJFRvLfwjrgsoig9nWmfFLX9IkbIEhFKdFrEQO/nEWqsJzez4KQKtRNQk5mmfA6ipksY e9pDy3K/jVWRpOrjHy79DTAQ/buAJ3p01MAKbgPkLxAp1Okf9cnlVuMvaan3hS/Fn6i5 auuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date; bh=lxIa+S5lty5IVAMiPNcjl7k1BGKoOjGZbz4c6nnRfXA=; fh=3hK9dq2h/fPNqsoZvw/8gEG7LthF4VE/Apazs7+V3cw=; b=ljO7KJbcb0/4WPYWNVqGHO22PLUqtHL5gnN+qQdeU2DlpYmKTI3piY5enVWom8/kSl zBbV1ZCzlwWzb4MWMyZjnLYCXq8d0XuE8SwOPtVXaA2d0L1JT7k9OpcbfGdUypOA/wCW xER4cjyWwaId0DTvryRzABMbccFqn397zNH0+bxVGaXFMdnBBKWobnzDdSJKaUtHLgwK XwglhQD62H8zOtbEpvRxgAkJYIe3S8gvOLHrKstloYWO1EVmtuWiEV9quGhK+228JHQ5 DyZKVIxbMYNQum1ggHVVdcu+l2A+r4a4mvDiDICuiGsZBQPMTtGRqqn2pTaVDWGfyDim Q1Gg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-30220-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30220-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n5-20020a634d45000000b005be27af74basi1558754pgl.33.2024.01.18.06.48.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 06:48:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30220-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-30220-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30220-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AAE2BB230B6 for ; Thu, 18 Jan 2024 14:45:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF965208A1; Thu, 18 Jan 2024 14:45:29 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45A481E4A1 for ; Thu, 18 Jan 2024 14:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705589128; cv=none; b=JnmvlZNjF7q1QYHswm5WFdVocWpJlFXyf8N5BQLnt6qIPyn/XSZ9mZXq80MeUe9fRL276Rdw/dwETKqZdSZQx4P2HNh6wCCjQALUjEKrAgNFdlJ6mkjm4GlZmKvPlmdQzDwN+bJpigwdvmrSllyM7XuUCwgpMqqK4z6NqReet0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705589128; c=relaxed/simple; bh=jWDkfChzYYvTaG6H6B35gjloWDfYxgMr/RX4Mzi9osU=; h=Received:Date:From:To:Cc:Subject:Message-ID:X-Mailer:MIME-Version: Content-Type:Content-Transfer-Encoding; b=Y5yawU1VNspqh+FBDw7gRRnOYcC6PhrY6xYZBsaBM8VA+x6MvoBefwUrKnn3uNkd+VLiJ18xPPPR/ZCbf4E7yxJpfC8rpZ0tomBweV7lJaWOcYKCmB1r2osr3lj6i4dEOY4Hiw2MhfrZebOhnqmuvnc+m/g/YeCRJdhtR0hY8h8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F007FC433F1; Thu, 18 Jan 2024 14:45:26 +0000 (UTC) Date: Thu, 18 Jan 2024 09:46:45 -0500 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Masami Hiramatsu , Mathieu Desnoyers , Erick Archer , Nathan Lynch Subject: [GIT PULL] eventfs: Fix for readdir and a seq_buf fix Message-ID: <20240118094645.58edbfb7@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788440045999919349 X-GMAIL-MSGID: 1788440045999919349 Linus, This includes the fix to eventfs that we discussed. It removes the creation of dentries/inodes from the readdir() logic. I also threw in a seq_buf fix that was sent to me not to long ago. More eventfs fixes and a seq_buf fix for 6.8: - Hard-code the inodes for eventfs to the same number for files, and the same number for directories. - Have getdent() not create dentries/inodes in iterate_shared() as now it has hard-coded inode numbers - Use kcalloc() instead of kzalloc() on a list of elements - Fix seq_buf warning and make static work properly. Please pull the latest eventfs-v6.8-2 tree, which can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git eventfs-v6.8-2 Tag SHA1: 09d733778820003cca5836364cbc0b162d70bb7e Head SHA1: 7a8e9cdf9405819105ae7405cd91e482bf574b01 Erick Archer (1): eventfs: Use kcalloc() instead of kzalloc() Nathan Lynch (1): seq_buf: Make DECLARE_SEQ_BUF() usable Steven Rostedt (Google) (2): eventfs: Have the inodes all for files and directories all be the same eventfs: Do not create dentries nor inodes in iterate_shared ---- fs/tracefs/event_inode.c | 36 ++++++++++++++++++------------------ include/linux/seq_buf.h | 3 +-- 2 files changed, 19 insertions(+), 20 deletions(-) --------------------------- diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index fdff53d5a1f8..6795fda2af19 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -32,6 +32,10 @@ */ static DEFINE_MUTEX(eventfs_mutex); +/* Choose something "unique" ;-) */ +#define EVENTFS_FILE_INODE_INO 0x12c4e37 +#define EVENTFS_DIR_INODE_INO 0x134b2f5 + /* * The eventfs_inode (ei) itself is protected by SRCU. It is released from * its parent's list and will have is_freed set (under eventfs_mutex). @@ -93,7 +97,7 @@ static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry, /* Preallocate the children mode array if necessary */ if (!(dentry->d_inode->i_mode & S_IFDIR)) { if (!ei->entry_attrs) { - ei->entry_attrs = kzalloc(sizeof(*ei->entry_attrs) * ei->nr_entries, + ei->entry_attrs = kcalloc(ei->nr_entries, sizeof(*ei->entry_attrs), GFP_NOFS); if (!ei->entry_attrs) { ret = -ENOMEM; @@ -352,6 +356,9 @@ static struct dentry *create_file(const char *name, umode_t mode, inode->i_fop = fop; inode->i_private = data; + /* All files will have the same inode number */ + inode->i_ino = EVENTFS_FILE_INODE_INO; + ti = get_tracefs(inode); ti->flags |= TRACEFS_EVENT_INODE; d_instantiate(dentry, inode); @@ -388,6 +395,9 @@ static struct dentry *create_dir(struct eventfs_inode *ei, struct dentry *parent inode->i_op = &eventfs_root_dir_inode_operations; inode->i_fop = &eventfs_file_operations; + /* All directories will have the same inode number */ + inode->i_ino = EVENTFS_DIR_INODE_INO; + ti = get_tracefs(inode); ti->flags |= TRACEFS_EVENT_INODE; @@ -717,8 +727,6 @@ static int eventfs_iterate(struct file *file, struct dir_context *ctx) struct eventfs_inode *ei_child; struct tracefs_inode *ti; struct eventfs_inode *ei; - struct dentry *ei_dentry = NULL; - struct dentry *dentry; const char *name; umode_t mode; int idx; @@ -739,11 +747,11 @@ static int eventfs_iterate(struct file *file, struct dir_context *ctx) mutex_lock(&eventfs_mutex); ei = READ_ONCE(ti->private); - if (ei && !ei->is_freed) - ei_dentry = READ_ONCE(ei->dentry); + if (ei && ei->is_freed) + ei = NULL; mutex_unlock(&eventfs_mutex); - if (!ei || !ei_dentry) + if (!ei) goto out; /* @@ -770,11 +778,7 @@ static int eventfs_iterate(struct file *file, struct dir_context *ctx) if (r <= 0) continue; - dentry = create_file_dentry(ei, i, ei_dentry, name, mode, cdata, fops); - if (!dentry) - goto out; - ino = dentry->d_inode->i_ino; - dput(dentry); + ino = EVENTFS_FILE_INODE_INO; if (!dir_emit(ctx, name, strlen(name), ino, DT_REG)) goto out; @@ -798,11 +802,7 @@ static int eventfs_iterate(struct file *file, struct dir_context *ctx) name = ei_child->name; - dentry = create_dir_dentry(ei, ei_child, ei_dentry); - if (!dentry) - goto out_dec; - ino = dentry->d_inode->i_ino; - dput(dentry); + ino = EVENTFS_DIR_INODE_INO; if (!dir_emit(ctx, name, strlen(name), ino, DT_DIR)) goto out_dec; @@ -874,7 +874,7 @@ struct eventfs_inode *eventfs_create_dir(const char *name, struct eventfs_inode } if (size) { - ei->d_children = kzalloc(sizeof(*ei->d_children) * size, GFP_KERNEL); + ei->d_children = kcalloc(size, sizeof(*ei->d_children), GFP_KERNEL); if (!ei->d_children) { kfree_const(ei->name); kfree(ei); @@ -941,7 +941,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry goto fail; if (size) { - ei->d_children = kzalloc(sizeof(*ei->d_children) * size, GFP_KERNEL); + ei->d_children = kcalloc(size, sizeof(*ei->d_children), GFP_KERNEL); if (!ei->d_children) goto fail; } diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 5fb1f12c33f9..c44f4b47b945 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -22,9 +22,8 @@ struct seq_buf { }; #define DECLARE_SEQ_BUF(NAME, SIZE) \ - char __ ## NAME ## _buffer[SIZE] = ""; \ struct seq_buf NAME = { \ - .buffer = &__ ## NAME ## _buffer, \ + .buffer = (char[SIZE]) { 0 }, \ .size = SIZE, \ }