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

Re: [PATCH][RHEL5.4] sleep for N seconds before getting ks file (#460566)



> So, the try-again logic needs to be repeated a few times as shown in the
> attached proof-of-concept patch (not tested yet!).
>   - not needed for NFS or Url since those aren't local USB devices.

I think doing the same sort of exponential backoff plan for files via a
URL is important too, since we can run into all sorts of problems there.
NFS is probably less important.

>   - Floppy and CD need to re-try probeDevices() a few times
>   - HD and BD need to re-try mounting the device in  
> getFileFromBlockDevice()
>
> The Floppy code already sleeps for USB devices, so I copied-and-pasted  
> it for CDs (but increased the sleep to 2 seconds).
>
> For HD & BD, I did something slightly differently and did an exponential  
> backoff as Chris suggested.

Sounsd good to me.  I think you are definitely on the right track here.

Note that we'll want to get this into Fedora as well and there will be
significant differences in the code.  Among them, you shouldn't need to
pass a filesystem type besides "auto" anymore.

> @@ -655,9 +658,16 @@ int getFileFromBlockDevice(char *device, char *path, char * dest) {
>          return 1;
>      }
>  
> -    if (doPwMount("/tmp/srcdev", "/tmp/mnt", "vfat", IMOUNT_RDONLY, NULL) &&
> -        doPwMount("/tmp/srcdev", "/tmp/mnt", "ext2", IMOUNT_RDONLY, NULL) && 
> -        doPwMount("/tmp/srcdev", "/tmp/mnt", "iso9660", IMOUNT_RDONLY, NULL)) {
> +    /* some USB thumb drives and hard drives are slow to initialize */
> +    /* retry up to 5 times or 31 seconds */
> +    rc = TRYMOUNT("vfat") && TRYMOUNT("ext2") && TRYMOUNT("iso9660");
> +    while (rc && (i++ < 5)) {
> +        sleep(s);
> +        s <<= 1;
> +        logMessage(DEBUGLVL, "sleeping to wait for USB storage devices");
> +        rc = TRYMOUNT("vfat") && TRYMOUNT("ext2") && TRYMOUNT("iso9660");
> +    }
> +    if (rc) {
>          logMessage(ERROR, "failed to mount /dev/%s: %s", device,
>                     strerror(errno));
>          return 2;

I never really like relying on the preprocessor too much, but other than
that I don't have any complaints here.

- Chris


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