The patch titled Subject: relay: make create_buf_file and remove_buf_file callbacks mandatory has been added to the -mm tree. Its filename is relay-make-create_buf_file-and-remove_buf_file-callbacks-mandatory.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/relay-make-create_buf_file-and-remove_buf_file-callbacks-mandatory.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/relay-make-create_buf_file-and-remove_buf_file-callbacks-mandatory.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Jani Nikula <jani.nikula@xxxxxxxxx> Subject: relay: make create_buf_file and remove_buf_file callbacks mandatory All clients provide create_buf_file and remove_buf_file callbacks, and they're required for relay to make sense. There is no point in them being optional. Also document whether each callback is mandatory/optional. Link: https://lkml.kernel.org/r/88003c1527386b93036e286e7917f1e33aec84ac.1606153547.git.jani.nikula@xxxxxxxxx Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx> Suggested-by: Christoph Hellwig <hch@xxxxxxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Kalle Valo <kvalo@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/relay.h | 6 ++++++ kernel/relay.c | 26 +------------------------- 2 files changed, 7 insertions(+), 25 deletions(-) --- a/include/linux/relay.h~relay-make-create_buf_file-and-remove_buf_file-callbacks-mandatory +++ a/include/linux/relay.h @@ -89,6 +89,8 @@ struct rchan_callbacks * The client should return 1 to continue logging, 0 to stop * logging. * + * This callback is optional. + * * NOTE: subbuf_start will also be invoked when the buffer is * created, so that the first sub-buffer can be initialized * if necessary. In this case, prev_subbuf will be NULL. @@ -122,6 +124,8 @@ struct rchan_callbacks * cause relay_open() to create a single global buffer rather * than the default set of per-cpu buffers. * + * This callback is mandatory. + * * See Documentation/filesystems/relay.rst for more info. */ struct dentry *(*create_buf_file)(const char *filename, @@ -139,6 +143,8 @@ struct rchan_callbacks * channel buffer. * * The callback should return 0 if successful, negative if not. + * + * This callback is mandatory. */ int (*remove_buf_file)(struct dentry *dentry); }; --- a/kernel/relay.c~relay-make-create_buf_file-and-remove_buf_file-callbacks-mandatory +++ a/kernel/relay.c @@ -271,26 +271,6 @@ static int subbuf_start_default_callback return 1; } -/* - * create_buf_file_create() default callback. Does nothing. - */ -static struct dentry *create_buf_file_default_callback(const char *filename, - struct dentry *parent, - umode_t mode, - struct rchan_buf *buf, - int *is_global) -{ - return NULL; -} - -/* - * remove_buf_file() default callback. Does nothing. - */ -static int remove_buf_file_default_callback(struct dentry *dentry) -{ - return -EINVAL; -} - /** * wakeup_readers - wake up readers waiting on a channel * @work: contains the channel buffer @@ -467,10 +447,6 @@ static void setup_callbacks(struct rchan { if (!cb->subbuf_start) cb->subbuf_start = subbuf_start_default_callback; - if (!cb->create_buf_file) - cb->create_buf_file = create_buf_file_default_callback; - if (!cb->remove_buf_file) - cb->remove_buf_file = remove_buf_file_default_callback; chan->cb = cb; } @@ -530,7 +506,7 @@ struct rchan *relay_open(const char *bas return NULL; if (subbuf_size > UINT_MAX / n_subbufs) return NULL; - if (!cb) + if (!cb || !cb->create_buf_file || !cb->remove_buf_file) return NULL; chan = kzalloc(sizeof(struct rchan), GFP_KERNEL); _ Patches currently in -mm which might be from jani.nikula@xxxxxxxxx are relay-remove-unused-buf_mapped-and-buf_unmapped-callbacks.patch relay-require-non-null-callbacks-in-relay_open.patch relay-make-create_buf_file-and-remove_buf_file-callbacks-mandatory.patch relay-allow-the-use-of-const-callback-structs.patch drm-i915-make-relay-callbacks-const.patch ath10k-make-relay-callbacks-const.patch ath11k-make-relay-callbacks-const.patch ath9k-make-relay-callbacks-const.patch blktrace-make-relay-callbacks-const.patch