Re: [PATCH v2 3/3] btrfs-progs: fi defrag: extend -c to drop nocompress flag on files

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

 



On Wed, Nov 29, 2017 at 09:54:01AM +0800, Su Yue wrote:
> On 11/29/2017 12:07 AM, David Sterba wrote:
> > On Tue, Nov 28, 2017 at 05:14:50PM +0800, Su Yue wrote:
> >> Now, files which have nocompress flag also will be defraged
> >> with compression. However, nocompress flag is still existed
> >> and have to be cleared manually.
> >>
> >> So add an option '--clear-nocompress' to extend -c to drop
> >> nocompress flag after defragement.
> > 
> >> Suggested-by: David Sterba <dsterba@xxxxxxxx>
> >> Suggested-by: Anand Jain <anand.jain@xxxxxxxxxx>
> > 
> > Do you have the pointer to the discussion? The whole idea sounds
> > familiar and seeing my name here means I must have been involved, but I
> > have only vague memories.
> > 
> 
> Here is the link:
> https://www.spinics.net/lists/linux-btrfs/msg67529.html

Thanks.

> >> +static int clear_nocompress_flag(int fd)
> >> +{
> >> +	unsigned int flags;
> >> +	int ret = 0;
> >> +
> >> +	ret = ioctl(fd, FS_IOC_GETFLAGS, &flags);
> >> +	if (ret < 0) {
> >> +		ret = -errno;
> >> +		error("failed to get flags: %s", strerror(-ret));
> >> +		goto out;
> >> +	}
> >> +
> >> +	if (!(flags & FS_NOCOMP_FL)) {
> >> +		ret = 0;
> >> +		goto out;
> >> +	}
> >> +	flags &= ~FS_NOCOMP_FL;
> >> +	ret = ioctl(fd, FS_IOC_SETFLAGS, &flags);
> > 
> > This is inherently racy, but the inode flags do not change that often so
> > concurrent change is unlikely.
> > 
> 
> I don't quite understand what you mean.
> Could you explain some details?

If the inode flags change externally between the set and get calls, but
there's not much we can do about it now.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux