From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Zefan Subject: Re: [PATCH 12/12] cgroup: unify pidlist and other file handling Date: Wed, 4 Dec 2013 14:20:22 +0800 Message-ID: <529EC9A6.903@huawei.com> References: <1385595759-17656-1-git-send-email-tj@kernel.org> <1385595759-17656-13-git-send-email-tj@kernel.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1385595759-17656-13-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Tejun Heo Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org, hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org, mhocko-AlSwsSmVLrQ@public.gmane.org, bsingharora-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org, nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org, daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org, arozansk-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org > +static void *cgroup_seqfile_start(struct seq_file *seq, loff_t *ppos) > +{ > + struct cftype *cft = seq_cft(seq); > + > + if (cft->seq_start) { > + return cft->seq_start(seq, ppos); > + } else { > + /* > + * The same behavior and code as single_open(). Returns > + * !NULL if pos is at the beginning; otherwise, NULL. > + */ Isn't it simpler to choose between seq_open() and single_open() depending on if cft->seq_start is implemented? > + return NULL + !*ppos; > + } > +} ... > static int cgroup_file_open(struct inode *inode, struct file *file) > { > struct cfent *cfe = __d_cfe(file->f_dentry); > @@ -2338,20 +2384,17 @@ static int cgroup_file_open(struct inode *inode, struct file *file) > WARN_ON_ONCE(cfe->css && cfe->css != css); > cfe->css = css; > > - if (cft->open) { > - err = cft->open(inode, file); > - } else { > - err = single_open_size(file, cgroup_seqfile_show, cfe, > - sizeof(struct cgroup_open_file)); > - if (!err) { > - struct seq_file *sf = file->private_data; > - struct cgroup_open_file *of = sf->private; > + err = seq_open_private(file, &cgroup_seq_operations, > + sizeof(struct cgroup_open_file)); > + if (!err) { > + struct seq_file *sf = file->private_data; > + struct cgroup_open_file *of = sf->private; > > - of->cfe = cfe; > - } > + of->cfe = cfe; > + return 0; > } > > - if (css->ss && err) > + if (css->ss) > css_put(css); > return err; > }