[stgt] behavior of RO file system

ronnie sahlberg ronniesahlberg at gmail.com
Sat Jun 4 06:41:48 CEST 2011


Tomo,

Please find attached a patch for the fix that Daisuke Fujita showed below


regards
ronnie sahlberg


On Fri, Jun 3, 2011 at 3:17 PM, FUJITA Tomonori
<fujita.tomonori at lab.ntt.co.jp> wrote:
> On Thu, 02 Jun 2011 21:23:23 +0900
> Daisuke Fujita <fuzita.daisuke at jp.fujitsu.com> wrote:
>
>> Dear developers,
>>
>> I got the "tgtadm: invalid request" message when I executed the
>> following command.
>>
>> # tgtadm --lld iscsi --op new --mode logicalunit --tid=1 --lun 1 -b
>> /media/CentOS_5.4_Final/RELEASE-NOTES-en.html
>> tgtadm: invalid request
>> # tail /var/log/messages
>> Jun  2 20:52:58 cent_54_agt_fu2 tgtd: backed_file_open(92) Could not open
>> /media/CentOS_5.4_Final/RELEASE-NOTES-en.html, Read-only file system
>>
>> I think that "backed_file_open" method may return with EROFS in addition
>> to EACCES so tgtd should handle it. What do you think?
>>
>> EROFS   pathname refers to a file on a read-only filesystem and write
>>         access was requested.
>>
>> Reference:
>> - bstype = rdwr (usr/bs_rdwr.c)
>> static int bs_rdwr_open(struct scsi_lu *lu, char *path, int *fd, uint64_t
>> *size)
>> {
>>       *fd = backed_file_open(path, O_RDWR|O_LARGEFILE|lu->bsoflags, size);
>>         /* If we get access denied, try opening the file in readonly mode */
>>       if (*fd == -1 && errno == EACCES) {
>>                 *fd = backed_file_open(path,
>> O_RDONLY|O_LARGEFILE|lu->bsoflags,
>>                                        size);
>>                 lu->attrs.readonly = 1;
>>         }
>>         if (*fd < 0)
>>                 return *fd;
>>
>>         return 0;
>> }
>>
>> - bstype=aio (usr/bs_aio.c)
>> static int bs_aio_open(struct scsi_lu *lu, char *path, int *fd, uint64_t
>> *size)
>> {
>>       *fd = backed_file_open(path, O_RDWR|O_LARGEFILE|O_DIRECT, size);
>>         /* If we get access denied, try opening the file in readonly mode */
>>       if (*fd == -1 && errno == EACCES) {
>>                 *fd = backed_file_open(path, O_RDONLY|O_LARGEFILE|O_DIRECT,
>>                                        size);
>>                 lu->attrs.readonly = 1;
>>         }
>>         if (*fd < 0)
>>                 return *fd;
>>         return 0;
>> }
>>
>> When I changed the condition "if (*fd == -1 && errno == EACCES)" to
>> "if (*fd == -1 && (errno == EACCES || errno == EROFS))", it works as
>> I expected.
>
> Thanks, the fix sounds good to me.
>
> Can you send a patch?
> --
> To unsubscribe from this list: send the line "unsubscribe stgt" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Try-open-the-backing-file-as-readonly-if-the-initial.patch.gz
Type: application/x-gzip
Size: 687 bytes
Desc: not available
URL: <http://lists.wpkg.org/pipermail/stgt/attachments/20110604/35edc28e/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Try-open-the-backing-file-as-readonly-if-the-initial.patch
Type: text/x-diff
Size: 1607 bytes
Desc: not available
URL: <http://lists.wpkg.org/pipermail/stgt/attachments/20110604/35edc28e/attachment-0002.patch>


More information about the stgt mailing list