tracing: Two small fixes for tracefs and eventfs:

- Fix register_snapshot_trigger() on allocation error
   If the snapshot fails to allocate, the register_snapshot_trigger() can
   still return success. If the call to tracing_alloc_snapshot_instance()
   returned anything but 0, it returned 0, but it should have been returning
   the error code from that allocation function.
 
 - Remove leftover code from tracefs doing a dentry walk on remount.
   The update_gid() function was called by the tracefs code on remount
   to update the gid of eventfs, but that is no longer the case, but that
   code wasn't deleted. Nothing calls it. Remove it.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYIADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCZbcbZBQccm9zdGVkdEBn
 b29kbWlzLm9yZwAKCRAp5XQQmuv6qqEsAQCWTIQ/yAktP2doLvuccZbZSc5NFHZt
 hZNRHep/SMQqKwD6AlesgiXlXM39HiRTiV17jPzrL65brcTEYMJmqCaWugk=
 =8nia
 -----END PGP SIGNATURE-----

Merge tag 'trace-v6.8-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull tracing fixes from Steven Rostedt:
 "Two small fixes for tracefs and eventfs:

   - Fix register_snapshot_trigger() on allocation error

     If the snapshot fails to allocate, the register_snapshot_trigger()
     can still return success. If the call to
     tracing_alloc_snapshot_instance() returned anything but 0, it
     returned 0, but it should have been returning the error code from
     that allocation function.

   - Remove leftover code from tracefs doing a dentry walk on remount.

     The update_gid() function was called by the tracefs code on remount
     to update the gid of eventfs, but that is no longer the case, but
     that code wasn't deleted. Nothing calls it. Remove it"

* tag 'trace-v6.8-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  tracefs: remove stale 'update_gid' code
  tracing/trigger: Fix to return error if failed to alloc snapshot
This commit is contained in:
Linus Torvalds 2024-01-29 18:42:34 -08:00
commit 9b7bd05beb
3 changed files with 4 additions and 41 deletions

View file

@ -281,44 +281,6 @@ static void update_inode_attr(struct dentry *dentry, struct inode *inode,
inode->i_gid = attr->gid;
}
static void update_gid(struct eventfs_inode *ei, kgid_t gid, int level)
{
struct eventfs_inode *ei_child;
/* at most we have events/system/event */
if (WARN_ON_ONCE(level > 3))
return;
ei->attr.gid = gid;
if (ei->entry_attrs) {
for (int i = 0; i < ei->nr_entries; i++) {
ei->entry_attrs[i].gid = gid;
}
}
/*
* Only eventfs_inode with dentries are updated, make sure
* all eventfs_inodes are updated. If one of the children
* do not have a dentry, this function must traverse it.
*/
list_for_each_entry_srcu(ei_child, &ei->children, list,
srcu_read_lock_held(&eventfs_srcu)) {
if (!ei_child->dentry)
update_gid(ei_child, gid, level + 1);
}
}
void eventfs_update_gid(struct dentry *dentry, kgid_t gid)
{
struct eventfs_inode *ei = dentry->d_fsdata;
int idx;
idx = srcu_read_lock(&eventfs_srcu);
update_gid(ei, gid, 0);
srcu_read_unlock(&eventfs_srcu, idx);
}
/**
* create_file - create a file in the tracefs filesystem
* @name: the name of the file to create.

View file

@ -82,7 +82,6 @@ struct inode *tracefs_get_inode(struct super_block *sb);
struct dentry *eventfs_start_creating(const char *name, struct dentry *parent);
struct dentry *eventfs_failed_creating(struct dentry *dentry);
struct dentry *eventfs_end_creating(struct dentry *dentry);
void eventfs_update_gid(struct dentry *dentry, kgid_t gid);
void eventfs_set_ei_status_free(struct tracefs_inode *ti, struct dentry *dentry);
#endif /* _TRACEFS_INTERNAL_H */

View file

@ -1470,8 +1470,10 @@ register_snapshot_trigger(char *glob,
struct event_trigger_data *data,
struct trace_event_file *file)
{
if (tracing_alloc_snapshot_instance(file->tr) != 0)
return 0;
int ret = tracing_alloc_snapshot_instance(file->tr);
if (ret < 0)
return ret;
return register_trigger(glob, data, file);
}