|
Lines 234-239
static int sync_file(struct file * file,
Link Here
|
| 234 |
return ret; |
234 |
return ret; |
| 235 |
} |
235 |
} |
| 236 |
|
236 |
|
|
|
237 |
static int sync_file_unlocked(struct file *file) |
| 238 |
{ |
| 239 |
struct address_space *mapping; |
| 240 |
int ret; |
| 241 |
|
| 242 |
if (!file->f_op || !file->f_op->fsync) |
| 243 |
return -EOPNOTSUPP; |
| 244 |
|
| 245 |
mapping = file->f_mapping; |
| 246 |
|
| 247 |
ret = filemap_fdatawrite(mapping); |
| 248 |
if (!ret) { |
| 249 |
int ret2; |
| 250 |
|
| 251 |
mutex_lock(&mapping->host->i_mutex); |
| 252 |
ret = file->f_op->fsync(file, file->f_dentry, 1); |
| 253 |
mutex_unlock(&mapping->host->i_mutex); |
| 254 |
|
| 255 |
ret2 = filemap_fdatawait(mapping); |
| 256 |
if (!ret) |
| 257 |
ret = ret2; |
| 258 |
} |
| 259 |
|
| 260 |
return ret; |
| 261 |
} |
| 262 |
|
| 237 |
/** |
263 |
/** |
| 238 |
* do_lo_send_aops - helper for writing data to a loop device |
264 |
* do_lo_send_aops - helper for writing data to a loop device |
| 239 |
* |
265 |
* |
|
Lines 525-531
static int do_bio_filebacked(struct loop
Link Here
|
| 525 |
int barrier = bio_barrier(bio); |
551 |
int barrier = bio_barrier(bio); |
| 526 |
|
552 |
|
| 527 |
if (barrier) { |
553 |
if (barrier) { |
| 528 |
ret = sync_file(lo->lo_backing_file, 1); |
554 |
ret = sync_file_unlocked(lo->lo_backing_file); |
| 529 |
if (unlikely(ret)) |
555 |
if (unlikely(ret)) |
| 530 |
return ret; |
556 |
return ret; |
| 531 |
} |
557 |
} |
|
Lines 537-543
static int do_bio_filebacked(struct loop
Link Here
|
| 537 |
ret = lo_receive(lo, bio, lo->lo_blocksize, pos); |
563 |
ret = lo_receive(lo, bio, lo->lo_blocksize, pos); |
| 538 |
|
564 |
|
| 539 |
if ((barrier || sync) && !ret) |
565 |
if ((barrier || sync) && !ret) |
| 540 |
ret = sync_file(lo->lo_backing_file, 1); |
566 |
ret = sync_file_unlocked(lo->lo_backing_file); |
| 541 |
|
567 |
|
| 542 |
return ret; |
568 |
return ret; |
| 543 |
} |
569 |
} |