Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
Browse files Browse the repository at this point in the history
Pull exofs update from Boaz Harrosh:
 "They are all mostly fixes, except the most important patch by Artem
  Bityutskiy which removes the use of s_dirt.  After this patch s_dirt
  can be completely removed from the tree."

* 'for-linus' of git://git.open-osd.org/linux-open-osd:
  ore: Fix out-of-bounds access in _ios_obj()
  exofs: Use proper max_IO calculations from ore
  exofs: Fix __r4w_get_page when offset is beyond i_size
  exofs: stop using s_dirt
  exofs: readpage_strip: Add a BUG_ON to check for PageLocked(page)
  • Loading branch information
torvalds committed Aug 3, 2012
2 parents d79095e + 9e62bb4 commit d42d1da
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
27 changes: 18 additions & 9 deletions fs/exofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@

#define EXOFS_DBGMSG2(M...) do {} while (0)

enum {MAX_PAGES_KMALLOC = PAGE_SIZE / sizeof(struct page *), };

unsigned exofs_max_io_pages(struct ore_layout *layout,
unsigned expected_pages)
{
unsigned pages = min_t(unsigned, expected_pages, MAX_PAGES_KMALLOC);
unsigned pages = min_t(unsigned, expected_pages,
layout->max_io_length / PAGE_SIZE);

/* TODO: easily support bio chaining */
pages = min_t(unsigned, pages, layout->max_io_length / PAGE_SIZE);
return pages;
}

Expand Down Expand Up @@ -101,7 +98,8 @@ static void _pcol_reset(struct page_collect *pcol)
* it might not end here. don't be left with nothing
*/
if (!pcol->expected_pages)
pcol->expected_pages = MAX_PAGES_KMALLOC;
pcol->expected_pages =
exofs_max_io_pages(&pcol->sbi->layout, ~0);
}

static int pcol_try_alloc(struct page_collect *pcol)
Expand Down Expand Up @@ -389,6 +387,8 @@ static int readpage_strip(void *data, struct page *page)
size_t len;
int ret;

BUG_ON(!PageLocked(page));

/* FIXME: Just for debugging, will be removed */
if (PageUptodate(page))
EXOFS_ERR("PageUptodate(0x%lx, 0x%lx)\n", pcol->inode->i_ino,
Expand Down Expand Up @@ -572,8 +572,16 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate)

if (!pcol->that_locked_page ||
(pcol->that_locked_page->index != index)) {
struct page *page = find_get_page(pcol->inode->i_mapping, index);
struct page *page;
loff_t i_size = i_size_read(pcol->inode);

if (offset >= i_size) {
*uptodate = true;
EXOFS_DBGMSG("offset >= i_size index=0x%lx\n", index);
return ZERO_PAGE(0);
}

page = find_get_page(pcol->inode->i_mapping, index);
if (!page) {
page = find_or_create_page(pcol->inode->i_mapping,
index, GFP_NOFS);
Expand Down Expand Up @@ -602,12 +610,13 @@ static void __r4w_put_page(void *priv, struct page *page)
{
struct page_collect *pcol = priv;

if (pcol->that_locked_page != page) {
if ((pcol->that_locked_page != page) && (ZERO_PAGE(0) != page)) {
EXOFS_DBGMSG("index=0x%lx\n", page->index);
page_cache_release(page);
return;
}
EXOFS_DBGMSG("that_locked_page index=0x%lx\n", page->index);
EXOFS_DBGMSG("that_locked_page index=0x%lx\n",
ZERO_PAGE(0) == page ? -1 : page->index);
}

static const struct _ore_r4w_op _r4w_op = {
Expand Down
14 changes: 7 additions & 7 deletions fs/exofs/ore.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,11 +837,11 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp)
bio->bi_rw |= REQ_WRITE;
}

osd_req_write(or, _ios_obj(ios, dev), per_dev->offset,
bio, per_dev->length);
osd_req_write(or, _ios_obj(ios, cur_comp),
per_dev->offset, bio, per_dev->length);
ORE_DBGMSG("write(0x%llx) offset=0x%llx "
"length=0x%llx dev=%d\n",
_LLU(_ios_obj(ios, dev)->id),
_LLU(_ios_obj(ios, cur_comp)->id),
_LLU(per_dev->offset),
_LLU(per_dev->length), dev);
} else if (ios->kern_buff) {
Expand All @@ -853,20 +853,20 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp)
(ios->si.unit_off + ios->length >
ios->layout->stripe_unit));

ret = osd_req_write_kern(or, _ios_obj(ios, per_dev->dev),
ret = osd_req_write_kern(or, _ios_obj(ios, cur_comp),
per_dev->offset,
ios->kern_buff, ios->length);
if (unlikely(ret))
goto out;
ORE_DBGMSG2("write_kern(0x%llx) offset=0x%llx "
"length=0x%llx dev=%d\n",
_LLU(_ios_obj(ios, dev)->id),
_LLU(_ios_obj(ios, cur_comp)->id),
_LLU(per_dev->offset),
_LLU(ios->length), per_dev->dev);
} else {
osd_req_set_attributes(or, _ios_obj(ios, dev));
osd_req_set_attributes(or, _ios_obj(ios, cur_comp));
ORE_DBGMSG2("obj(0x%llx) set_attributes=%d dev=%d\n",
_LLU(_ios_obj(ios, dev)->id),
_LLU(_ios_obj(ios, cur_comp)->id),
ios->out_attr_len, dev);
}

Expand Down
11 changes: 0 additions & 11 deletions fs/exofs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,6 @@ static int exofs_sync_fs(struct super_block *sb, int wait)
ret = ore_write(ios);
if (unlikely(ret))
EXOFS_ERR("%s: ore_write failed.\n", __func__);
else
sb->s_dirt = 0;


unlock_super(sb);
Expand All @@ -412,14 +410,6 @@ static int exofs_sync_fs(struct super_block *sb, int wait)
return ret;
}

static void exofs_write_super(struct super_block *sb)
{
if (!(sb->s_flags & MS_RDONLY))
exofs_sync_fs(sb, 1);
else
sb->s_dirt = 0;
}

static void _exofs_print_device(const char *msg, const char *dev_path,
struct osd_dev *od, u64 pid)
{
Expand Down Expand Up @@ -952,7 +942,6 @@ static const struct super_operations exofs_sops = {
.write_inode = exofs_write_inode,
.evict_inode = exofs_evict_inode,
.put_super = exofs_put_super,
.write_super = exofs_write_super,
.sync_fs = exofs_sync_fs,
.statfs = exofs_statfs,
};
Expand Down

0 comments on commit d42d1da

Please sign in to comment.