Bug 435471

Summary: sg_turs reports false number when --number and --progress given
Product: Red Hat Enterprise Linux 5 Reporter: Milos Malik <mmalik>
Component: sg3_utilsAssignee: Phil Knirsch <pknirsch>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5.1CC: dhorak, rvokal
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-03-20 09:30:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Milos Malik 2008-02-29 15:55:18 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; cs-CZ; rv:1.8.1.12) Gecko/20080208 Fedora/2.0.0.12-1.fc8 Firefox/2.0.0.12

Description of problem:
When sg_turs is executed with parameters "--progress" and "--number", it always reports "Completed 1 Test Unit Ready commands". It does not matter how big positive number is given to --number, it always reports the same message.

According to man page the utility should wait 30 seconds before subsequent checks when parameters "--number" > 1 and "--progress" are given, but the utility exits immediately.

When the parameter "--progress" is omitted, the reported number of completed TEST UNIT READY commands is correct.

Version-Release number of selected component (if applicable):
sg3_utils-1.25-1

How reproducible:
Always


Steps to Reproduce:
1. sg_turs --number=1024 --progress /dev/sda
2. look at its output


Actual Results:
Its output is following:

Completed 1 Test Unit Ready commands

Expected Results:
Its output is following:

Completed 1024 Test Unit Ready commands

Additional info:

Comment 1 Dan HorĂ¡k 2008-03-20 09:30:24 UTC
There is misunderstanding of the --progress option. It shows a progress of a
SCSI command for a busy device, not a progress of the whole test.

See the full explanation of the --progress option in the man page,
especially the "exits when" part:
"show progress indication (a percentage) if available.  If --number=NUM is given
and NUM is greater than 1 then waits 30 seconds before subsequent checks. Exits
when NUM is reached or there is no more progress indication. Ignores --time option."

Becuase in your test case the device is not busy with any operation, then there
can be no progress to show, so it exits immediately. You should see a "progress"
when trying the following commands:
sg_format --format /dev/foo ; sg_turs --progress --num=100 /dev/foo
the formatting makes the device busy and that's why it cannot respond as "ready"

This conclusion is a result of studying the source code and a consultation with
the upstream author.