svn commit: r243246 - head/sbin/growfs

Edward Tomasz Napierała trasz at FreeBSD.org
Sun Nov 18 19:36:17 UTC 2012


Wiadomość napisana przez Gavin Atkinson w dniu 18 lis 2012, o godz. 20:25:
> On Sun, 18 Nov 2012, Edward Tomasz Napierala wrote:
> 
>> Author: trasz
>> Date: Sun Nov 18 19:01:00 2012
>> New Revision: 243246
>> URL: http://svnweb.freebsd.org/changeset/base/243246
>> 
>> Log:
>>  Make it possible to resize filesystems mounted read-write, using newly
>>  introduced UFS write suspension mechanism.
>> 
>> Modified: head/sbin/growfs/growfs.c
>> ==============================================================================
>> --- head/sbin/growfs/growfs.c	Sun Nov 18 18:57:19 2012	(r243245)
>> +++ head/sbin/growfs/growfs.c	Sun Nov 18 19:01:00 2012	(r243246)
>> @@ -1555,9 +1557,18 @@ main(int argc, char **argv)
>> 	if (Nflag) {
>> 		fso = -1;
>> 	} else {
>> -		fso = open(device, O_WRONLY);
>> -		if (fso < 0)
>> -			err(1, "%s", device);
>> +		if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) == 0) {
>> +			fso = open(_PATH_UFSSUSPEND, O_RDWR);
>> +			if (fso == -1)
>> +				err(1, "unable to open %s", _PATH_UFSSUSPEND);
>> +			error = ioctl(fso, UFSSUSPEND, &statfsp->f_fsid);
>> +			if (error != 0)
>> +				err(1, "UFSSUSPEND");
>> +		} else {
>> +			fso = open(device, O_WRONLY);
>> +			if (fso < 0)
>> +				err(1, "%s", device);
>> +		}
>> 	}
> 
> It is excellent to see this functionality, and it will be very much 
> appreciated especially for people using virtual machines.

Thanks!

> All the way through later code there are calls to err() on failure.  
> What happens to the suspended filesystem if that happens and growfs exits 
> before the matching UFSRESUME?

Kernel releases the suspension when the process keeping the filedescriptor
exits.  It could be said that the UFSRESUME ioctl is there mostly
for completeness.  And the changes performed by growfs(8) are ordered in
a way that keeps the filesystem consistent, so it should be safe to ^C
growfs execution without breaking things.

-- 
If you cut off my head, what would I say?  Me and my head, or me and my body?



More information about the svn-src-all mailing list