Skip to content

Commit bf25db3

Browse files
committed
Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
* 'for-linus' of git://git.open-osd.org/linux-open-osd: exofs: Fix groups code when num_devices is not divisible by group_width exofs: Remove useless optimization exofs: exofs_file_fsync and exofs_file_flush correctness exofs: Remove superfluous dependency on buffer_head and writeback
2 parents 682c30e + 5002dd1 commit bf25db3

File tree

4 files changed

+31
-52
lines changed

4 files changed

+31
-52
lines changed

fs/exofs/file.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,34 @@
3030
* along with exofs; if not, write to the Free Software
3131
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3232
*/
33-
34-
#include <linux/buffer_head.h>
35-
3633
#include "exofs.h"
3734

3835
static int exofs_release_file(struct inode *inode, struct file *filp)
3936
{
4037
return 0;
4138
}
4239

40+
/* exofs_file_fsync - flush the inode to disk
41+
*
42+
* Note, in exofs all metadata is written as part of inode, regardless.
43+
* The writeout is synchronous
44+
*/
4345
static int exofs_file_fsync(struct file *filp, int datasync)
4446
{
4547
int ret;
46-
struct address_space *mapping = filp->f_mapping;
47-
struct inode *inode = mapping->host;
48+
struct inode *inode = filp->f_mapping->host;
49+
struct writeback_control wbc = {
50+
.sync_mode = WB_SYNC_ALL,
51+
.nr_to_write = 0, /* metadata-only; caller takes care of data */
52+
};
4853
struct super_block *sb;
4954

50-
ret = filemap_write_and_wait(mapping);
51-
if (ret)
52-
return ret;
55+
if (!(inode->i_state & I_DIRTY))
56+
return 0;
57+
if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
58+
return 0;
5359

54-
/* sync the inode attributes */
55-
ret = write_inode_now(inode, 1);
60+
ret = sync_inode(inode, &wbc);
5661

5762
/* This is a good place to write the sb */
5863
/* TODO: Sechedule an sb-sync on create */
@@ -65,9 +70,9 @@ static int exofs_file_fsync(struct file *filp, int datasync)
6570

6671
static int exofs_flush(struct file *file, fl_owner_t id)
6772
{
68-
exofs_file_fsync(file, 1);
73+
int ret = vfs_fsync(file, 0);
6974
/* TODO: Flush the OSD target */
70-
return 0;
75+
return ret;
7176
}
7277

7378
const struct file_operations exofs_file_operations = {

fs/exofs/inode.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
*/
3333

3434
#include <linux/slab.h>
35-
#include <linux/writeback.h>
36-
#include <linux/buffer_head.h>
37-
#include <scsi/scsi_device.h>
3835

3936
#include "exofs.h"
4037

@@ -773,15 +770,13 @@ static int exofs_releasepage(struct page *page, gfp_t gfp)
773770
{
774771
EXOFS_DBGMSG("page 0x%lx\n", page->index);
775772
WARN_ON(1);
776-
return try_to_free_buffers(page);
773+
return 0;
777774
}
778775

779776
static void exofs_invalidatepage(struct page *page, unsigned long offset)
780777
{
781-
EXOFS_DBGMSG("page_has_buffers=>%d\n", page_has_buffers(page));
778+
EXOFS_DBGMSG("page 0x%lx offset 0x%lx\n", page->index, offset);
782779
WARN_ON(1);
783-
784-
block_invalidatepage(page, offset);
785780
}
786781

787782
const struct address_space_operations exofs_aops = {

fs/exofs/ios.c

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,6 @@ int exofs_check_io(struct exofs_io_state *ios, u64 *resid)
305305
struct _striping_info {
306306
u64 obj_offset;
307307
u64 group_length;
308-
u64 total_group_length;
309-
u64 Major;
310308
unsigned dev;
311309
unsigned unit_off;
312310
};
@@ -343,8 +341,6 @@ static void _calc_stripe_info(struct exofs_io_state *ios, u64 file_offset,
343341
(M * group_depth * stripe_unit);
344342

345343
si->group_length = T - H;
346-
si->total_group_length = T;
347-
si->Major = M;
348344
}
349345

350346
static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg,
@@ -392,20 +388,19 @@ static int _add_stripe_unit(struct exofs_io_state *ios, unsigned *cur_pg,
392388
}
393389

394390
static int _prepare_one_group(struct exofs_io_state *ios, u64 length,
395-
struct _striping_info *si, unsigned first_comp)
391+
struct _striping_info *si)
396392
{
397393
unsigned stripe_unit = ios->layout->stripe_unit;
398394
unsigned mirrors_p1 = ios->layout->mirrors_p1;
399395
unsigned devs_in_group = ios->layout->group_width * mirrors_p1;
400396
unsigned dev = si->dev;
401397
unsigned first_dev = dev - (dev % devs_in_group);
402-
unsigned comp = first_comp + (dev - first_dev);
403398
unsigned max_comp = ios->numdevs ? ios->numdevs - mirrors_p1 : 0;
404399
unsigned cur_pg = ios->pages_consumed;
405400
int ret = 0;
406401

407402
while (length) {
408-
struct exofs_per_dev_state *per_dev = &ios->per_dev[comp];
403+
struct exofs_per_dev_state *per_dev = &ios->per_dev[dev];
409404
unsigned cur_len, page_off = 0;
410405

411406
if (!per_dev->length) {
@@ -424,11 +419,8 @@ static int _prepare_one_group(struct exofs_io_state *ios, u64 length,
424419
cur_len = stripe_unit;
425420
}
426421

427-
if (max_comp < comp)
428-
max_comp = comp;
429-
430-
dev += mirrors_p1;
431-
dev = (dev % devs_in_group) + first_dev;
422+
if (max_comp < dev)
423+
max_comp = dev;
432424
} else {
433425
cur_len = stripe_unit;
434426
}
@@ -440,8 +432,8 @@ static int _prepare_one_group(struct exofs_io_state *ios, u64 length,
440432
if (unlikely(ret))
441433
goto out;
442434

443-
comp += mirrors_p1;
444-
comp = (comp % devs_in_group) + first_comp;
435+
dev += mirrors_p1;
436+
dev = (dev % devs_in_group) + first_dev;
445437

446438
length -= cur_len;
447439
}
@@ -454,18 +446,15 @@ static int _prepare_one_group(struct exofs_io_state *ios, u64 length,
454446
static int _prepare_for_striping(struct exofs_io_state *ios)
455447
{
456448
u64 length = ios->length;
449+
u64 offset = ios->offset;
457450
struct _striping_info si;
458-
unsigned devs_in_group = ios->layout->group_width *
459-
ios->layout->mirrors_p1;
460-
unsigned first_comp = 0;
461451
int ret = 0;
462452

463-
_calc_stripe_info(ios, ios->offset, &si);
464-
465453
if (!ios->pages) {
466454
if (ios->kern_buff) {
467455
struct exofs_per_dev_state *per_dev = &ios->per_dev[0];
468456

457+
_calc_stripe_info(ios, ios->offset, &si);
469458
per_dev->offset = si.obj_offset;
470459
per_dev->dev = si.dev;
471460

@@ -479,26 +468,17 @@ static int _prepare_for_striping(struct exofs_io_state *ios)
479468
}
480469

481470
while (length) {
471+
_calc_stripe_info(ios, offset, &si);
472+
482473
if (length < si.group_length)
483474
si.group_length = length;
484475

485-
ret = _prepare_one_group(ios, si.group_length, &si, first_comp);
476+
ret = _prepare_one_group(ios, si.group_length, &si);
486477
if (unlikely(ret))
487478
goto out;
488479

480+
offset += si.group_length;
489481
length -= si.group_length;
490-
491-
si.group_length = si.total_group_length;
492-
si.unit_off = 0;
493-
++si.Major;
494-
si.obj_offset = si.Major * ios->layout->stripe_unit *
495-
ios->layout->group_depth;
496-
497-
si.dev = (si.dev - (si.dev % devs_in_group)) + devs_in_group;
498-
si.dev %= ios->layout->s_numdevs;
499-
500-
first_comp += devs_in_group;
501-
first_comp %= ios->layout->s_numdevs;
502482
}
503483

504484
out:

fs/exofs/super.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3232
*/
3333

34-
#include <linux/smp_lock.h>
3534
#include <linux/string.h>
3635
#include <linux/parser.h>
3736
#include <linux/vfs.h>

0 commit comments

Comments
 (0)