[stgt] behavior of RO file system

Daisuke Fujita fuzita.daisuke at jp.fujitsu.com
Thu Jun 2 14:23:23 CEST 2011


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.

Best Regards,

Daisuke FUJITA



--
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



More information about the stgt mailing list