Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
fix issue jthornber#69 - ENOENT /sys/block/<dev>/queue/discard_granul…
Browse files Browse the repository at this point in the history
…arity

A lot of tests fail due to Errno::ENOENT: No such file or directory @ rb_sysopen - /sys/block/<dev>/queue/discard_granularity when dev is a partition instead of a disk, so we should first find the disk of the partition and then read the discard_granularity file of the disk.
  • Loading branch information
Simon Xu committed Sep 3, 2020
1 parent 86c7665 commit 8a86951
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/dmtest/discard_limits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ def initialize(dev)
private

def read_param(p)
disk = dev.to_s
type = `lsblk -n /dev/#{disk} | grep -w #{disk} | sed 's/[ \t]*$//; s/.*[ \t]//'`.strip
if type == "part"
disk = `basename $(dirname $(find /sys -type d -name #{disk}))`.strip
end
line = ''
File.open("/sys/block/#{dev.to_s}/queue/discard_#{p}", 'r') do |file|
File.open("/sys/block/#{disk}/queue/discard_#{p}", 'r') do |file|
line = file.gets
end

Expand Down

0 comments on commit 8a86951

Please sign in to comment.