[sheepdog] [PATCH v2 08/11] sheep: introduce sparse objects

MORITA Kazutaka morita.kazutaka at gmail.com
Mon Jul 1 02:08:43 CEST 2013


At Sun, 30 Jun 2013 15:11:39 +0800,
Kai Zhang wrote:
> 
> On Jun 30, 2013, at 2:53 PM, Kai Zhang <kyle at zelin.io> wrote:
> 
> > 
> > On Jun 19, 2013, at 1:14 AM, MORITA Kazutaka <morita.kazutaka at gmail.com> wrote:
> > 
> >> +static int discard(int fd, uint64_t start, uint32_t end)
> >> +{
> >> +	int ret = xfallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE,
> >> +			     start, end - start);
> >> +	if (ret < 0) {
> >> +		if (errno == ENOSYS || errno == EOPNOTSUPP)
> >> +			sd_iprintf("FALLOC_FL_PUNCH_HOLE is not supported "
> >> +				   "on this filesystem");
> >> +		else
> >> +			sd_eprintf("failed to discard object, %m");
> >> +	}
> >> +
> >> +	return ret;
> >> +}
> > 
> > Is there a way to check the supports of FALLOC_FL_PUNCH_HOLE at compile time?
> > So that we can reduce some unnecessary operations.
> > 
> > However, if there is a way, we can implement it in a separate patch.
> > 
> 
> On the second though, support of FALLOC_FL_PUNCH_HOLE is based on filesystem and
> maybe not easy to be decided at compile time.
> And the static variable "trim_is_supported" can avoid unnecessary checks.
> 
> However, if md is enabled, a single variable "trim_is_supported" is not powerful enough.
> Seems no easy way to mark each disk if it can support FALLOC_FL_PUNCH_HOLE.

I think using different file systems for sheepdog is rare case.  We
can disable discard even when one of disks doesn't support
FALLOC_FL_PUNCH_HOLE.

Thanks,

Kazutaka



More information about the sheepdog mailing list