[sheepdog] [PATCH] sheep: open files with O_EXCL when creating objects

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Fri Sep 14 08:15:43 CEST 2012


At Fri, 14 Sep 2012 12:43:42 +0800,
Liu Yuan wrote:
> 
> On 09/14/2012 12:26 PM, MORITA Kazutaka wrote:
> > Using O_TRUNC with O_EXCL doesn't make sense and I think we don't need
> > the flag at all.  This patch assumes that CREATE requests don't
> > overwrite objects with different content.  Is it wrong?
> 
> I don't have questions for the patch objective. But I'm not sure if
> there is previously existing object that has different content before we
> executing the CREATE request. can O_TRUNC act as a safe guard?

Well, truncating the temporary file is not necessary for that because
rename/2 completely replace the exiting object with new one.  So, what
we need to do here is retrying open when errno is EEXIST, or
introducing a lock to prevent multiple requests from opening the
temporary file at the same time.

However, IMHO, if we really need to consider such case, sheep should
return error rather than overwriting the object with a new
craete_and_write request.  But to implement it, we need to completely
rewrite default_create_and_write.  I'd suggest considering the case
after it actually happens.  Unless two clients use the same VDI at the
same time, I cannot imagine it at least for now.

Thanks,

Kazutaka



More information about the sheepdog mailing list