提交 d42d1dab 编写于 作者: L Linus Torvalds

Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd

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)
...@@ -37,15 +37,12 @@ ...@@ -37,15 +37,12 @@
#define EXOFS_DBGMSG2(M...) do {} while (0) #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 exofs_max_io_pages(struct ore_layout *layout,
unsigned expected_pages) 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; return pages;
} }
...@@ -101,7 +98,8 @@ static void _pcol_reset(struct page_collect *pcol) ...@@ -101,7 +98,8 @@ static void _pcol_reset(struct page_collect *pcol)
* it might not end here. don't be left with nothing * it might not end here. don't be left with nothing
*/ */
if (!pcol->expected_pages) 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) static int pcol_try_alloc(struct page_collect *pcol)
...@@ -389,6 +387,8 @@ static int readpage_strip(void *data, struct page *page) ...@@ -389,6 +387,8 @@ static int readpage_strip(void *data, struct page *page)
size_t len; size_t len;
int ret; int ret;
BUG_ON(!PageLocked(page));
/* FIXME: Just for debugging, will be removed */ /* FIXME: Just for debugging, will be removed */
if (PageUptodate(page)) if (PageUptodate(page))
EXOFS_ERR("PageUptodate(0x%lx, 0x%lx)\n", pcol->inode->i_ino, EXOFS_ERR("PageUptodate(0x%lx, 0x%lx)\n", pcol->inode->i_ino,
...@@ -572,8 +572,16 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate) ...@@ -572,8 +572,16 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate)
if (!pcol->that_locked_page || if (!pcol->that_locked_page ||
(pcol->that_locked_page->index != index)) { (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) { if (!page) {
page = find_or_create_page(pcol->inode->i_mapping, page = find_or_create_page(pcol->inode->i_mapping,
index, GFP_NOFS); index, GFP_NOFS);
...@@ -602,12 +610,13 @@ static void __r4w_put_page(void *priv, struct page *page) ...@@ -602,12 +610,13 @@ static void __r4w_put_page(void *priv, struct page *page)
{ {
struct page_collect *pcol = priv; 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); EXOFS_DBGMSG("index=0x%lx\n", page->index);
page_cache_release(page); page_cache_release(page);
return; 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 = { static const struct _ore_r4w_op _r4w_op = {
......
...@@ -837,11 +837,11 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp) ...@@ -837,11 +837,11 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp)
bio->bi_rw |= REQ_WRITE; bio->bi_rw |= REQ_WRITE;
} }
osd_req_write(or, _ios_obj(ios, dev), per_dev->offset, osd_req_write(or, _ios_obj(ios, cur_comp),
bio, per_dev->length); per_dev->offset, bio, per_dev->length);
ORE_DBGMSG("write(0x%llx) offset=0x%llx " ORE_DBGMSG("write(0x%llx) offset=0x%llx "
"length=0x%llx dev=%d\n", "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->offset),
_LLU(per_dev->length), dev); _LLU(per_dev->length), dev);
} else if (ios->kern_buff) { } else if (ios->kern_buff) {
...@@ -853,20 +853,20 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp) ...@@ -853,20 +853,20 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp)
(ios->si.unit_off + ios->length > (ios->si.unit_off + ios->length >
ios->layout->stripe_unit)); 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, per_dev->offset,
ios->kern_buff, ios->length); ios->kern_buff, ios->length);
if (unlikely(ret)) if (unlikely(ret))
goto out; goto out;
ORE_DBGMSG2("write_kern(0x%llx) offset=0x%llx " ORE_DBGMSG2("write_kern(0x%llx) offset=0x%llx "
"length=0x%llx dev=%d\n", "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->offset),
_LLU(ios->length), per_dev->dev); _LLU(ios->length), per_dev->dev);
} else { } 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", 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); ios->out_attr_len, dev);
} }
......
...@@ -400,8 +400,6 @@ static int exofs_sync_fs(struct super_block *sb, int wait) ...@@ -400,8 +400,6 @@ static int exofs_sync_fs(struct super_block *sb, int wait)
ret = ore_write(ios); ret = ore_write(ios);
if (unlikely(ret)) if (unlikely(ret))
EXOFS_ERR("%s: ore_write failed.\n", __func__); EXOFS_ERR("%s: ore_write failed.\n", __func__);
else
sb->s_dirt = 0;
unlock_super(sb); unlock_super(sb);
...@@ -412,14 +410,6 @@ static int exofs_sync_fs(struct super_block *sb, int wait) ...@@ -412,14 +410,6 @@ static int exofs_sync_fs(struct super_block *sb, int wait)
return ret; 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, static void _exofs_print_device(const char *msg, const char *dev_path,
struct osd_dev *od, u64 pid) struct osd_dev *od, u64 pid)
{ {
...@@ -952,7 +942,6 @@ static const struct super_operations exofs_sops = { ...@@ -952,7 +942,6 @@ static const struct super_operations exofs_sops = {
.write_inode = exofs_write_inode, .write_inode = exofs_write_inode,
.evict_inode = exofs_evict_inode, .evict_inode = exofs_evict_inode,
.put_super = exofs_put_super, .put_super = exofs_put_super,
.write_super = exofs_write_super,
.sync_fs = exofs_sync_fs, .sync_fs = exofs_sync_fs,
.statfs = exofs_statfs, .statfs = exofs_statfs,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册