mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
Merge tag 'trace-seq-file-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into for-next
Pull the beginning of seq_file cleanup from Steven: "I'm looking to clean up the seq_file code and to eventually merge the trace_seq code with seq_file as well, since they basically do the same thing. Part of this process is to remove the return code of seq_printf() and friends as they are rather inconsistent. It is better to use the new function seq_has_overflowed() if you want to stop processing when the buffer is full. Note, if the buffer is full, the seq_file code will throw away the contents, allocate a bigger buffer, and then call your code again to fill in the data. The only thing that breaking out of the function early does is to save a little time which is probably never noticed. I started with patches from Joe Perches and modified them as well. There's many more places that need to be updated before we can convert seq_printf() and friends to return void. But this patch set introduces the seq_has_overflowed() and does some initial updates."
This commit is contained in:
commit
8ce74dd605
38 changed files with 410 additions and 437 deletions
|
|
@ -20,25 +20,24 @@
|
|||
|
||||
#if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY)
|
||||
|
||||
static int show_fdinfo(struct seq_file *m, struct file *f,
|
||||
int (*show)(struct seq_file *m, struct fsnotify_mark *mark))
|
||||
static void show_fdinfo(struct seq_file *m, struct file *f,
|
||||
void (*show)(struct seq_file *m,
|
||||
struct fsnotify_mark *mark))
|
||||
{
|
||||
struct fsnotify_group *group = f->private_data;
|
||||
struct fsnotify_mark *mark;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&group->mark_mutex);
|
||||
list_for_each_entry(mark, &group->marks_list, g_list) {
|
||||
ret = show(m, mark);
|
||||
if (ret)
|
||||
show(m, mark);
|
||||
if (seq_has_overflowed(m))
|
||||
break;
|
||||
}
|
||||
mutex_unlock(&group->mark_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_EXPORTFS)
|
||||
static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
|
||||
static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
|
||||
{
|
||||
struct {
|
||||
struct file_handle handle;
|
||||
|
|
@ -52,71 +51,62 @@ static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
|
|||
ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
|
||||
if ((ret == FILEID_INVALID) || (ret < 0)) {
|
||||
WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
f.handle.handle_type = ret;
|
||||
f.handle.handle_bytes = size * sizeof(u32);
|
||||
|
||||
ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
|
||||
f.handle.handle_bytes, f.handle.handle_type);
|
||||
seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
|
||||
f.handle.handle_bytes, f.handle.handle_type);
|
||||
|
||||
for (i = 0; i < f.handle.handle_bytes; i++)
|
||||
ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
|
||||
|
||||
return ret;
|
||||
seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
|
||||
}
|
||||
#else
|
||||
static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
|
||||
static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_INOTIFY_USER
|
||||
|
||||
static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
|
||||
static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
|
||||
{
|
||||
struct inotify_inode_mark *inode_mark;
|
||||
struct inode *inode;
|
||||
int ret = 0;
|
||||
|
||||
if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE)))
|
||||
return 0;
|
||||
return;
|
||||
|
||||
inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
|
||||
inode = igrab(mark->i.inode);
|
||||
if (inode) {
|
||||
ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x "
|
||||
"mask:%x ignored_mask:%x ",
|
||||
inode_mark->wd, inode->i_ino,
|
||||
inode->i_sb->s_dev,
|
||||
mark->mask, mark->ignored_mask);
|
||||
ret |= show_mark_fhandle(m, inode);
|
||||
ret |= seq_putc(m, '\n');
|
||||
seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ",
|
||||
inode_mark->wd, inode->i_ino, inode->i_sb->s_dev,
|
||||
mark->mask, mark->ignored_mask);
|
||||
show_mark_fhandle(m, inode);
|
||||
seq_putc(m, '\n');
|
||||
iput(inode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int inotify_show_fdinfo(struct seq_file *m, struct file *f)
|
||||
void inotify_show_fdinfo(struct seq_file *m, struct file *f)
|
||||
{
|
||||
return show_fdinfo(m, f, inotify_fdinfo);
|
||||
show_fdinfo(m, f, inotify_fdinfo);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_INOTIFY_USER */
|
||||
|
||||
#ifdef CONFIG_FANOTIFY
|
||||
|
||||
static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
|
||||
static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
|
||||
{
|
||||
unsigned int mflags = 0;
|
||||
struct inode *inode;
|
||||
int ret = 0;
|
||||
|
||||
if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE))
|
||||
return 0;
|
||||
return;
|
||||
|
||||
if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)
|
||||
mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
|
||||
|
|
@ -124,26 +114,22 @@ static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
|
|||
if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) {
|
||||
inode = igrab(mark->i.inode);
|
||||
if (!inode)
|
||||
goto out;
|
||||
ret = seq_printf(m, "fanotify ino:%lx sdev:%x "
|
||||
"mflags:%x mask:%x ignored_mask:%x ",
|
||||
inode->i_ino, inode->i_sb->s_dev,
|
||||
mflags, mark->mask, mark->ignored_mask);
|
||||
ret |= show_mark_fhandle(m, inode);
|
||||
ret |= seq_putc(m, '\n');
|
||||
return;
|
||||
seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ",
|
||||
inode->i_ino, inode->i_sb->s_dev,
|
||||
mflags, mark->mask, mark->ignored_mask);
|
||||
show_mark_fhandle(m, inode);
|
||||
seq_putc(m, '\n');
|
||||
iput(inode);
|
||||
} else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) {
|
||||
struct mount *mnt = real_mount(mark->m.mnt);
|
||||
|
||||
ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x "
|
||||
"ignored_mask:%x\n", mnt->mnt_id, mflags,
|
||||
mark->mask, mark->ignored_mask);
|
||||
seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n",
|
||||
mnt->mnt_id, mflags, mark->mask, mark->ignored_mask);
|
||||
}
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fanotify_show_fdinfo(struct seq_file *m, struct file *f)
|
||||
void fanotify_show_fdinfo(struct seq_file *m, struct file *f)
|
||||
{
|
||||
struct fsnotify_group *group = f->private_data;
|
||||
unsigned int flags = 0;
|
||||
|
|
@ -169,7 +155,7 @@ int fanotify_show_fdinfo(struct seq_file *m, struct file *f)
|
|||
seq_printf(m, "fanotify flags:%x event-flags:%x\n",
|
||||
flags, group->fanotify_data.f_flags);
|
||||
|
||||
return show_fdinfo(m, f, fanotify_fdinfo);
|
||||
show_fdinfo(m, f, fanotify_fdinfo);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FANOTIFY */
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ struct file;
|
|||
#ifdef CONFIG_PROC_FS
|
||||
|
||||
#ifdef CONFIG_INOTIFY_USER
|
||||
extern int inotify_show_fdinfo(struct seq_file *m, struct file *f);
|
||||
void inotify_show_fdinfo(struct seq_file *m, struct file *f);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FANOTIFY
|
||||
extern int fanotify_show_fdinfo(struct seq_file *m, struct file *f);
|
||||
void fanotify_show_fdinfo(struct seq_file *m, struct file *f);
|
||||
#endif
|
||||
|
||||
#else /* CONFIG_PROC_FS */
|
||||
|
|
|
|||
Loading…
Reference in a new issue