Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

9p: Do a couple of cleanups

Do a couple of cleanups to 9p:

(1) Remove a couple of unused variables.

(2) Turn a BUG_ON() into a warning, consolidate with another warning and
make the warning message include the inode number rather than
whatever's in i_private (which will get hashed anyway).

Suggested-by: Dominique Martinet <asmadeus@codewreck.org>
Link: https://lore.kernel.org/r/ZZULNQAZ0n0WQv7p@codewreck.org/
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Dominique Martinet <asmadeus@codewreck.org>
cc: Eric Van Hensbergen <ericvh@kernel.org>
cc: Latchesar Ionkov <lucho@ionkov.net>
cc: Christian Schoenebeck <linux_oss@crudebyte.com>
cc: v9fs@lists.linux.dev
cc: linux-cachefs@redhat.com
cc: linux-fsdevel@vger.kernel.org

+9 -8
+9 -8
fs/9p/vfs_addr.c
··· 28 28 29 29 static void v9fs_upload_to_server(struct netfs_io_subrequest *subreq) 30 30 { 31 - struct inode *inode = subreq->rreq->inode; 32 - struct v9fs_inode __maybe_unused *v9inode = V9FS_I(inode); 33 31 struct p9_fid *fid = subreq->rreq->netfs_priv; 34 32 int err; 35 33 ··· 96 98 97 99 if (file) { 98 100 fid = file->private_data; 99 - BUG_ON(!fid); 101 + if (!fid) 102 + goto no_fid; 100 103 p9_fid_get(fid); 101 104 } else { 102 105 fid = v9fs_fid_find_inode(rreq->inode, writing, INVALID_UID, true); 103 - if (!fid) { 104 - WARN_ONCE(1, "folio expected an open fid inode->i_private=%p\n", 105 - rreq->inode->i_private); 106 - return -EINVAL; 107 - } 106 + if (!fid) 107 + goto no_fid; 108 108 } 109 109 110 110 /* we might need to read from a fid that was opened write-only ··· 111 115 WARN_ON(rreq->origin == NETFS_READ_FOR_WRITE && !(fid->mode & P9_ORDWR)); 112 116 rreq->netfs_priv = fid; 113 117 return 0; 118 + 119 + no_fid: 120 + WARN_ONCE(1, "folio expected an open fid inode->i_ino=%lx\n", 121 + rreq->inode->i_ino); 122 + return -EINVAL; 114 123 } 115 124 116 125 /**