* [PATCH] fs.h: introduce functions to get/set file->private_data @ 2010-08-16 18:37 H Hartley Sweeten 2010-08-16 23:17 ` Christoph Hellwig 0 siblings, 1 reply; 13+ messages in thread From: H Hartley Sweeten @ 2010-08-16 18:37 UTC (permalink / raw) To: Linux Kernel; +Cc: linux-fsdevel, matthew The symbol 'private_data' is commonly used and makes grep'ing for specific uses difficult. Introduce the wrapper functions file_get_privdata and file_set_privdata to help with the struct file uses. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Matthew Wilcox <matthew@wil.cx> --- diff --git a/include/linux/fs.h b/include/linux/fs.h index 9a96b4d..b357a17 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -961,6 +961,16 @@ extern spinlock_t files_lock; #define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) #define file_count(x) atomic_long_read(&(x)->f_count) +static inline void *file_get_privdata(struct file *file) +{ + return file->private_data; +} + +static inline void file_set_privdata(struct file *file, void *data) +{ + file->private_data = data; +} + #ifdef CONFIG_DEBUG_WRITECOUNT static inline void file_take_write(struct file *f) { ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-16 18:37 [PATCH] fs.h: introduce functions to get/set file->private_data H Hartley Sweeten @ 2010-08-16 23:17 ` Christoph Hellwig 2010-08-16 23:36 ` H Hartley Sweeten 0 siblings, 1 reply; 13+ messages in thread From: Christoph Hellwig @ 2010-08-16 23:17 UTC (permalink / raw) To: H Hartley Sweeten; +Cc: Linux Kernel, linux-fsdevel, matthew On Mon, Aug 16, 2010 at 11:37:52AM -0700, H Hartley Sweeten wrote: > The symbol 'private_data' is commonly used and makes grep'ing for > specific uses difficult. Introduce the wrapper functions file_get_privdata > and file_set_privdata to help with the struct file uses. This just obsfucates the code, NAK. ^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-16 23:17 ` Christoph Hellwig @ 2010-08-16 23:36 ` H Hartley Sweeten 2010-08-16 23:50 ` Joe Perches 0 siblings, 1 reply; 13+ messages in thread From: H Hartley Sweeten @ 2010-08-16 23:36 UTC (permalink / raw) To: Christoph Hellwig Cc: Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx On Monday, August 16, 2010 4:18 PM, Christoph Hellwig wrote: > On Mon, Aug 16, 2010 at 11:37:52AM -0700, H Hartley Sweeten wrote: >> The symbol 'private_data' is commonly used and makes grep'ing for >> specific uses difficult. Introduce the wrapper functions file_get_privdata >> and file_set_privdata to help with the struct file uses. > > This just obsfucates the code, NAK. Not a problem. It's just a pain trying to figure out where the file 'private_data' is being used. $ git grep private_data | wc -w 37272 $ git grep private_data include | wc -w 1068 The following struct's all have a 'void *private_data' symbol in include/linux: struct ac97_codec struct c2port_device struct file struct gendisk struct ata_host struct ata_queued_cmd struct ata_device struct ata_port struct ata_port_info struct parport struct rchan struct rtc_task struct plat_serial8250_port struct uart_port include/rdma and include/sound also have a number. Thanks for the reply. Regards, Hartley ^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-16 23:36 ` H Hartley Sweeten @ 2010-08-16 23:50 ` Joe Perches 2010-08-17 1:03 ` Ted Ts'o 0 siblings, 1 reply; 13+ messages in thread From: Joe Perches @ 2010-08-16 23:50 UTC (permalink / raw) To: H Hartley Sweeten Cc: Christoph Hellwig, Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx On Mon, 2010-08-16 at 18:36 -0500, H Hartley Sweeten wrote: > It's just a pain trying to figure out where the file 'private_data' is being > used. spatch (coccinelle) could help a lot with this style problem. For instance, here's a grep equivalent for any use of (struct file) member private_data in directory fs $ cat t.cocci @@ struct file *file; @@ * file->private_data $ spatch -very_quiet -sp_file t.cocci fs ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-16 23:50 ` Joe Perches @ 2010-08-17 1:03 ` Ted Ts'o 2010-08-17 1:58 ` Joe Perches ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Ted Ts'o @ 2010-08-17 1:03 UTC (permalink / raw) To: Joe Perches Cc: H Hartley Sweeten, Christoph Hellwig, Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx And spatch could also be used to rename private_data to f_private_data if people really cared.... - Ted ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-17 1:03 ` Ted Ts'o @ 2010-08-17 1:58 ` Joe Perches 2010-08-17 8:54 ` Christoph Hellwig [not found] ` <20100817085428.GA25330@infradead.org> 2 siblings, 0 replies; 13+ messages in thread From: Joe Perches @ 2010-08-17 1:58 UTC (permalink / raw) To: Ted Ts'o Cc: H Hartley Sweeten, Christoph Hellwig, Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx On Mon, 2010-08-16 at 21:03 -0400, Ted Ts'o wrote: > And spatch could also be used to rename private_data to f_private_data > if people really cared.... In struct file, private_data is the only member not prefixed with f_. It's a small .cocci file, but treewide, it's a relatively big patch. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-17 1:03 ` Ted Ts'o 2010-08-17 1:58 ` Joe Perches @ 2010-08-17 8:54 ` Christoph Hellwig [not found] ` <20100817085428.GA25330@infradead.org> 2 siblings, 0 replies; 13+ messages in thread From: Christoph Hellwig @ 2010-08-17 8:54 UTC (permalink / raw) To: Ted Ts'o, Joe Perches, H Hartley Sweeten, Christoph Hellwig, Linux Kernel On Mon, Aug 16, 2010 at 09:03:55PM -0400, Ted Ts'o wrote: > And spatch could also be used to rename private_data to f_private_data > if people really cared.... Agreed, that's much better than adding useless accessors. ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <20100817085428.GA25330@infradead.org>]
* Re: [PATCH] fs.h: introduce functions to get/set file->private_data [not found] ` <20100817085428.GA25330@infradead.org> @ 2010-08-17 17:26 ` Joe Perches 2010-08-17 17:58 ` Sam Ravnborg 0 siblings, 1 reply; 13+ messages in thread From: Joe Perches @ 2010-08-17 17:26 UTC (permalink / raw) To: Christoph Hellwig Cc: Ted Ts'o, H Hartley Sweeten, Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx On Tue, 2010-08-17 at 04:54 -0400, Christoph Hellwig wrote: > On Mon, Aug 16, 2010 at 09:03:55PM -0400, Ted Ts'o wrote: > > And spatch could also be used to rename private_data to f_private_data > > if people really cared.... > Agreed, that's much better than adding useless accessors. Against Linus' current, it's ~850KB. Anyone really want it? $ git diff --shortstat 495 files changed, 2526 insertions(+), 2529 deletions(-) $ git diff --stat -p > f_private_data.diff $ ls -la f_private_data.diff -rw-r--r-- 1 joe joe 853136 2010-08-17 10:19 f_private_data.diff ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-17 17:26 ` Joe Perches @ 2010-08-17 17:58 ` Sam Ravnborg 2010-08-17 18:21 ` Joe Perches 2010-08-18 1:32 ` Joe Perches 0 siblings, 2 replies; 13+ messages in thread From: Sam Ravnborg @ 2010-08-17 17:58 UTC (permalink / raw) To: Joe Perches Cc: Christoph Hellwig, Ted Ts'o, H Hartley Sweeten, Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx On Tue, Aug 17, 2010 at 10:26:13AM -0700, Joe Perches wrote: > On Tue, 2010-08-17 at 04:54 -0400, Christoph Hellwig wrote: > > On Mon, Aug 16, 2010 at 09:03:55PM -0400, Ted Ts'o wrote: > > > And spatch could also be used to rename private_data to f_private_data > > > if people really cared.... > > Agreed, that's much better than adding useless accessors. > > Against Linus' current, it's ~850KB. > Anyone really want it? This clearly shows how big the effort would be to introduce access functions. And if the only gain is grepability then such a cleanup patch is far more convinient. It takes minimum effort to create and test, and if you can get ack from Ted and/or Christoph there is a good chance Linus would take it right before/after -rc1. You obviously need to convince him that the patch has seen decent build testing. Sam ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-17 17:58 ` Sam Ravnborg @ 2010-08-17 18:21 ` Joe Perches 2010-08-18 1:32 ` Joe Perches 1 sibling, 0 replies; 13+ messages in thread From: Joe Perches @ 2010-08-17 18:21 UTC (permalink / raw) To: Sam Ravnborg Cc: Christoph Hellwig, Ted Ts'o, H Hartley Sweeten, Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx On Tue, 2010-08-17 at 19:58 +0200, Sam Ravnborg wrote: > On Tue, Aug 17, 2010 at 10:26:13AM -0700, Joe Perches wrote: > > On Tue, 2010-08-17 at 04:54 -0400, Christoph Hellwig wrote: > > > On Mon, Aug 16, 2010 at 09:03:55PM -0400, Ted Ts'o wrote: > > > > And spatch could also be used to rename private_data to f_private_data > > > > if people really cared.... > > > Agreed, that's much better than adding useless accessors. > > Against Linus' current, it's ~850KB. > > Anyone really want it? > a cleanup patch is far more convinient. > It takes minimum effort to create and test, and if you can > get ack from Ted and/or Christoph there is a good chance Linus > would take it right before/after -rc1. > You obviously need to convince him that the patch has > seen decent build testing. I don't have the passel of cross compilers, so someone else would need to do that. I compiled it 32 bit x86 allyesconfig only. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-17 17:58 ` Sam Ravnborg 2010-08-17 18:21 ` Joe Perches @ 2010-08-18 1:32 ` Joe Perches 2010-08-18 16:48 ` H Hartley Sweeten 1 sibling, 1 reply; 13+ messages in thread From: Joe Perches @ 2010-08-18 1:32 UTC (permalink / raw) To: Sam Ravnborg Cc: Christoph Hellwig, Ted Ts'o, H Hartley Sweeten, Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx On Tue, 2010-08-17 at 19:58 +0200, Sam Ravnborg wrote: > It takes minimum effort to create and test, and if you can > get ack from Ted and/or Christoph there is a good chance Linus > would take it right before/after -rc1. > > You obviously need to convince him that the patch has > seen decent build testing. private_data is the only non f_ prefixed member in struct file, so while there is perhaps a tiny value in this patch, I'm not in a hurry to push it. After a few corrections, Documentation/, comment and printk updates, a few macros that spatch didn't update, etc, the diff that converts struct file member private_data to f_private_data is now: $ git diff --shortstat ..da5cabf80e2433131bf0ed8993abc0f7ea618c73 511 files changed, 2638 insertions(+), 2639 deletions(-) Does either Ted or Christoph want to see it? Harley? You want it? It's still ~850BKB and probably shouldn't be posted to the ML as it's mostly mechanical. Compiles x86 allyesconfig, defconfig ^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-18 1:32 ` Joe Perches @ 2010-08-18 16:48 ` H Hartley Sweeten 2010-08-18 17:15 ` Joe Perches 0 siblings, 1 reply; 13+ messages in thread From: H Hartley Sweeten @ 2010-08-18 16:48 UTC (permalink / raw) To: Joe Perches, Sam Ravnborg Cc: Christoph Hellwig, Ted Ts'o, Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx On Tuesday, August 17, 2010 6:32 PM, Joe Perches wrote: > On Tue, 2010-08-17 at 19:58 +0200, Sam Ravnborg wrote: >> It takes minimum effort to create and test, and if you can >> get ack from Ted and/or Christoph there is a good chance Linus >> would take it right before/after -rc1. >> >> You obviously need to convince him that the patch has >> seen decent build testing. > > private_data is the only non f_ prefixed member in > struct file, so while there is perhaps a tiny value > in this patch, I'm not in a hurry to push it. > > After a few corrections, Documentation/, comment and > printk updates, a few macros that spatch didn't update, > etc, the diff that converts struct file member > private_data to f_private_data is now: > > $ git diff --shortstat ..da5cabf80e2433131bf0ed8993abc0f7ea618c73 > 511 files changed, 2638 insertions(+), 2639 deletions(-) > > Does either Ted or Christoph want to see it? > > Harley? You want it? Uh... No... ;-) > It's still ~850BKB and probably shouldn't be posted to > the ML as it's mostly mechanical. I would like to see it merged just to ease grepping but if no one else sees any benefit doing it I can live with it. FWIW, the only reason for bringing this up in the first place was I was trying to find all the places that have unnecessary casts when using the private_data. Stuff like: struct my_struct *my_data = (struct my_struct *)file->private_data; Maybe it would be simpler to use spatch to just fix those? > Compiles x86 allyesconfig, defconfig Regards, Hartley ^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH] fs.h: introduce functions to get/set file->private_data 2010-08-18 16:48 ` H Hartley Sweeten @ 2010-08-18 17:15 ` Joe Perches 0 siblings, 0 replies; 13+ messages in thread From: Joe Perches @ 2010-08-18 17:15 UTC (permalink / raw) To: H Hartley Sweeten Cc: Sam Ravnborg, Christoph Hellwig, Ted Ts'o, Linux Kernel, linux-fsdevel@vger.kernel.org, matthew@wil.cx On Wed, 2010-08-18 at 11:48 -0500, H Hartley Sweeten wrote: > FWIW, the only reason for bringing this up in the first place was I was > trying to find all the places that have unnecessary casts when using > the private_data. Stuff like: > > struct my_struct *my_data = (struct my_struct *)file->private_data; > > Maybe it would be simpler to use spatch to just fix those? I submitted that patch last month. About half have been applied. (I generally link to lkml.org, but it seems down) http://linux.derkeiler.com/Mailing-Lists/Kernel/2010-07/msg04333.html I also delete the remaining casts in this conversion. ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2010-08-18 17:15 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-16 18:37 [PATCH] fs.h: introduce functions to get/set file->private_data H Hartley Sweeten
2010-08-16 23:17 ` Christoph Hellwig
2010-08-16 23:36 ` H Hartley Sweeten
2010-08-16 23:50 ` Joe Perches
2010-08-17 1:03 ` Ted Ts'o
2010-08-17 1:58 ` Joe Perches
2010-08-17 8:54 ` Christoph Hellwig
[not found] ` <20100817085428.GA25330@infradead.org>
2010-08-17 17:26 ` Joe Perches
2010-08-17 17:58 ` Sam Ravnborg
2010-08-17 18:21 ` Joe Perches
2010-08-18 1:32 ` Joe Perches
2010-08-18 16:48 ` H Hartley Sweeten
2010-08-18 17:15 ` Joe Perches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).