[sheepdog] [PATCH v3 3/7] sheep: teach journal file to handle epoch and config write

Liu Yuan namei.unix at gmail.com
Fri Apr 5 10:55:00 CEST 2013


On 04/05/2013 04:33 PM, Hitoshi Mitake wrote:
> At Thu,  4 Apr 2013 20:49:38 +0800,
> Liu Yuan wrote:
>>
>> From: Liu Yuan <tailai.ly at taobao.com>
>>
>> journal_write_epoch and journal_write_confi is a placeholder for future use.
> 
> This commit message is obsolete. You should update it.
> 
> BTW, confi for expressing config files would be confusing. I think
> config is more suitable.
> 
>>  static int replay_journal_entry(struct journal_descriptor *jd)
>>  {
>>  	char path[PATH_MAX];
>> @@ -136,20 +165,17 @@ static int replay_journal_entry(struct journal_descriptor *jd)
>>  	void *buf;
>>  	char *p = (char *)jd;
>>  
>> -	sd_dprintf("%"PRIx64", size %"PRIu64", off %"PRIu64", %d", jd->oid,
>> -		   jd->size, jd->offset, jd->create);
>> -
>>  	if (jd->create)
>>  		flags |= O_CREAT;
>> -	snprintf(path, sizeof(path), "%s/%016" PRIx64, get_object_path(jd->oid),
>> -		 jd->oid);
>> +
>> +	journal_get_path(jd, path);
>>  	fd = open(path, flags, def_fmode);
>>  	if (fd < 0) {
>>  		sd_eprintf("open %m");
>>  		return -1;
>>  	}
>>  
>> -	if (jd->create) {
>> +	if (jd->create && jd->flag == JF_STORE) {
>>  		ret = prealloc(fd, get_objsize(jd->oid));
>>  		if (ret < 0)
>>  			goto out;
>> @@ -315,22 +341,15 @@ retry:
>>  		panic("%s", strerror(err));
>>  }
> 
> replay_journal_entry() lacks free(buf);
> 

Good catch.

>>  }
>> +
>> +int journal_write_store(uint64_t oid, const char *buf, size_t size,
>> +			off_t offset, bool create)
>> +{
>> +	struct journal_descriptor jd = {
>> +		.magic = JOURNAL_DESC_MAGIC,
>> +		.flag = JF_STORE,
>> +		.offset = offset,
>> +		.size = size,
>> +		.oid = oid,
> 
> The compile error still rises.

Oops, forgot to move this line.


> 
>>  	if (uatomic_is_true(&sys->use_journal) &&
>> -	    journal_file_write(oid, iocb->buf, iocb->length, iocb->offset,
>> -			       false)
>> +	    journal_write_store(oid, iocb->buf, iocb->length, iocb->offset,
>> +				false)
>>  	    != SD_RES_SUCCESS) {
>>  		sd_eprintf("turn off journaling");
>>  		uatomic_set_false(&sys->use_journal);
> 
> Is this behavior, turning off journaling and continuing, suitable?
> From my perspective, at least a behavior which causes death of sheep
> when writing journal fails should be supported as an optional one.
> 

Your advice is reasonable, but the error handling would be better
considered when journaling is set as default. Let's keep this patch set
small.

Thanks,
Yuan




More information about the sheepdog mailing list