Skip to content

Commit c7f864d

Browse files
Naman Jaingregkh
authored andcommitted
Drivers: hv: Make the sysfs node size for the ring buffer dynamic
commit 65995e9 upstream. The ring buffer size varies across VMBus channels. The size of sysfs node for the ring buffer is currently hardcoded to 4 MB. Userspace clients either use fstat() or hardcode this size for doing mmap(). To address this, make the sysfs node size dynamic to reflect the actual ring buffer size for each channel. This will ensure that fstat() on ring sysfs node always returns the correct size of ring buffer. Reviewed-by: Michael Kelley <[email protected]> Tested-by: Michael Kelley <[email protected]> Reviewed-by: Dexuan Cui <[email protected]> Signed-off-by: Naman Jain <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ The structure "struct attribute_group" does not have bin_size field in v6.12.x kernel so the logic of configuring size of sysfs node for ring buffer has been moved to vmbus_chan_bin_attr_is_visible(). Original change was not a fix, but it needs to be backported to fix size related discrepancy caused by the commit mentioned in Fixes tag. ] Signed-off-by: Naman Jain <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent beddf74 commit c7f864d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hv/vmbus_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,6 @@ static struct bin_attribute chan_attr_ring_buffer = {
18101810
.name = "ring",
18111811
.mode = 0600,
18121812
},
1813-
.size = 2 * SZ_2M,
18141813
.mmap = hv_mmap_ring_buffer_wrapper,
18151814
};
18161815
static struct attribute *vmbus_chan_attrs[] = {
@@ -1866,6 +1865,7 @@ static umode_t vmbus_chan_bin_attr_is_visible(struct kobject *kobj,
18661865
/* Hide ring attribute if channel's ring_sysfs_visible is set to false */
18671866
if (attr == &chan_attr_ring_buffer && !channel->ring_sysfs_visible)
18681867
return 0;
1868+
attr->size = channel->ringbuffer_pagecount << PAGE_SHIFT;
18691869

18701870
return attr->attr.mode;
18711871
}

0 commit comments

Comments
 (0)