[commits] [batman-adv] master: batman-adv: convert stream-like files from nonseekable_open -> stream_open (337ae19a)

postmaster at open-mesh.org postmaster at open-mesh.org
Sat May 18 13:56:54 CEST 2019


Repository : ssh://git@open-mesh.org/batman-adv

On branch  : master

>---------------------------------------------------------------

commit 337ae19a00d4455cf84afa58abfb432f78c882b9
Author: Kirill Smelkov <kirr at nexedi.com>
Date:   Sat May 11 21:17:09 2019 +0200

    batman-adv: convert stream-like files from nonseekable_open -> stream_open
    
    Using scripts/coccinelle/api/stream_open.cocci added in 10dce8af3422
    ("fs: stream_open - opener for stream-like files so that read and write
    can run simultaneously without deadlock"), search and convert to
    stream_open all in-kernel nonseekable_open users for which read and
    write actually do not depend on ppos and where there is no other methods
    in file_operations which assume @offset access.
    
    I've verified each generated change manually - that it is correct to convert -
    and each other nonseekable_open instance left - that it is either not correct
    to convert there, or that it is not converted due to current stream_open.cocci
    limitations.
    
    One can also recheck/review the patch via generating it with explanation comments included via
    
            $ make coccicheck MODE=patch COCCI=scripts/coccinelle/api/stream_open.cocci SPFLAGS="-D explain"
    
    Signed-off-by: Kirill Smelkov <kirr at nexedi.com>
    [sven at narfation.org: added compat code]
    Signed-off-by: Sven Eckelmann <sven at narfation.org>


>---------------------------------------------------------------

337ae19a00d4455cf84afa58abfb432f78c882b9
 compat-include/linux/fs.h    | 11 +++++++++++
 net/batman-adv/icmp_socket.c |  2 +-
 net/batman-adv/log.c         |  2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/compat-include/linux/fs.h b/compat-include/linux/fs.h
index c52e0e8e..480722f0 100644
--- a/compat-include/linux/fs.h
+++ b/compat-include/linux/fs.h
@@ -31,4 +31,15 @@ static inline struct dentry *batadv_file_dentry(const struct file *file)
 
 #endif /* < KERNEL_VERSION(4, 6, 0) */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)
+
+static inline int batadv_stream_open(struct inode *inode, struct file *filp)
+{
+	return nonseekable_open(inode, filp);
+}
+
+#define stream_open batadv_stream_open
+
+#endif /* < KERNEL_VERSION(5, 2, 0) */
+
 #endif	/* _NET_BATMAN_ADV_COMPAT_LINUX_FS_H_ */
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index de81b5ec..0a91c866 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -65,7 +65,7 @@ static int batadv_socket_open(struct inode *inode, struct file *file)
 
 	batadv_debugfs_deprecated(file, "");
 
-	nonseekable_open(inode, file);
+	stream_open(inode, file);
 
 	socket_client = kmalloc(sizeof(*socket_client), GFP_KERNEL);
 	if (!socket_client) {
diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c
index 60ce11e1..f79ebd5b 100644
--- a/net/batman-adv/log.c
+++ b/net/batman-adv/log.c
@@ -90,7 +90,7 @@ static int batadv_log_open(struct inode *inode, struct file *file)
 	batadv_debugfs_deprecated(file,
 				  "Use tracepoint batadv:batadv_dbg instead\n");
 
-	nonseekable_open(inode, file);
+	stream_open(inode, file);
 	file->private_data = inode->i_private;
 	return 0;
 }



More information about the commits mailing list