]> www.infradead.org Git - users/dwmw2/linux.git/commit
net: hns3: Resolved the issue that the debugfs query result is inconsistent.
authorHao Lan <lanhao@huawei.com>
Mon, 6 Jan 2025 14:36:38 +0000 (22:36 +0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 8 Jan 2025 18:33:14 +0000 (10:33 -0800)
commit5191a8d3c2ab5bc01930ea3425e06a739af5b0e9
tree55888427ac677982f6bf4432ae70c456c150aea0
parentac1e2836fe294c2007ca81cf7006862c3bdf0510
net: hns3: Resolved the issue that the debugfs query result is inconsistent.

This patch modifies the implementation of debugfs:

When the user process stops unexpectedly, not all data of the file system
is read. In this case, the save_buf pointer is not released. When the
user process is called next time, save_buf is used to copy the cached
data to the user space. As a result, the queried data is stale.

To solve this problem, this patch implements .open() and .release() handler
for debugfs file_operations. moving allocation buffer and execution
of the cmd to the .open() handler and freeing in to the .release() handler.
Allocate separate buffer for each reader and associate the buffer
with the file pointer.
When different user read processes no longer share the buffer,
the stale data problem is fixed.

Fixes: 5e69ea7ee2a6 ("net: hns3: refactor the debugfs process")
Signed-off-by: Hao Lan <lanhao@huawei.com>
Signed-off-by: Guangwei Zhang <zhangwangwei6@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Link: https://patch.msgid.link/20250106143642.539698-4-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c