Re: [PATCH 1/1] Add DISK media support to TGTIMG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 5, 2010 at 2:41 PM, FUJITA Tomonori
<fujita.tomonori@xxxxxxxxxxxxx> wrote:
> On Sun, 4 Apr 2010 08:13:47 +1000
> ronnie sahlberg <ronniesahlberg@xxxxxxxxx> wrote:
>
>> From c235db24c4b5eacf269926ad6e34498f25103fb5 Mon Sep 17 00:00:00 2001
>> From: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
>> Date: Sun, 4 Apr 2010 08:07:33 +1000
>> Subject: [PATCH] Update TGTIMG to use it to create DISK images.
>>  This is a trivial reimplementation of dd if=/dev/zero bs=1M ...
>>  but offers us to use one command for any type of media.
>>
>> Update the manpage for TGTIMG to describe how to use TGTIMG
>> to create DISK media.
>>
>> Change the example in README.iser to use TGTIMG instead of dd to
>> create the mediafile.
>>
>> Signed-off-by: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
>> ---
>>  doc/README.iser             |    3 +-
>>  doc/htmlpages/tgtimg.8.html |   32 +++++++++++--------
>>  doc/manpages/tgtimg.8       |   29 ++++++++++++-----
>>  doc/tgtimg.8.xml            |   26 ++++++++++-----
>>  usr/tgtimg.c                |   71 +++++++++++++++++++++++++++++++++++++++++++
>>  5 files changed, 129 insertions(+), 32 deletions(-)
>>
>> diff --git a/doc/README.iser b/doc/README.iser
>> index 2361c4e..f96e7aa 100644
>> --- a/doc/README.iser
>> +++ b/doc/README.iser
>> @@ -189,7 +189,8 @@ Configure the running target with one or more devices, using the tgtadm
>>  program you just built (also as root).  Full information is in
>>  doc/README.iscsi.  Here is a quick-start guide:
>>
>> -     dd if=/dev/zero bs=1k count=1 seek=1048575 of=/tmp/tid1lun1
>> +     ./tgtimg --op new --device-type disk --type disk --size 1024 \
>> +              --file /tmp/tid1lun1
>
> The operations are slightly different. The previous operation using dd
> creates a sparse file. tgtimg doesn't.
>
> Worth adding the sparse option to tgtimg? I'm not sure.

((there is no sense code for "filesystem full))


I can add a --sparse if you want one.
I think default should be non-sparse since that avoids the "surprise" of
hosting filesysem 100% full,   total dataloss for all LUNs with data
not yet destaged :-(

I personally don't think one should ever use sparse files in this kind
of application.

Some filesystems, such as XFS, support filesystem-specific code to
perform preallocation
of data blocks, which could be used.
That would however introduce fs-specific code into tgtimg.


I can add a --sparse if you or others want it.



>
>> +static int sbc_new(int op, char *path, char *capacity, char *media_type)
>> +{
>> +     int fd;
>> +
>> +     if (!strncasecmp("disk", media_type, 4)) {
>> +             uint32_t pos, size;
>> +             char *buf;
>> +
>> +             sscanf(capacity, "%d", &size);
>> +             if (size == 0) {
>
> if (!size) is preferred.
>
>
>> +                     printf("Capacity must be > 0\n");
>> +                     exit(3);
>> +             }
>> +
>> +             buf = malloc(1024*1024);
>> +             if (buf == NULL) {
>
> If (!buf) is preferred.
>
> I can fix them so I'll merge this patch.
>
> Thanks,
>


thanks for applying the patch.

regards
ronnie sahlberg
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux