X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdfilter%2Ffilter.c;h=ec8c0cb8887ae89d0ba2d9c4b6723c6759dec0d6;hb=34851570fbf48a3ba02f3f40ae6adc9b3c97cda1;hp=43217f53960e49a92ccd23509690b945a086c0ea;hpb=38e0b3bbfd8b74c3aa725e04f4b16435b29b5a2d;p=fs%2Flustre-release.git diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 43217f5..ec8c0cb 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -89,6 +89,7 @@ static int filter_prep(struct obd_device *obddev) GOTO(out, rc = PTR_ERR(file)); } filp_close(file, 0); + /* FIXME: this is the same as the _file_ we just created? */ rc = simple_mkdir(current->fs->pwd, rootid, 0755); file = filp_open("D/status", O_RDWR | O_CREAT, 0700); @@ -122,6 +123,7 @@ static int filter_prep(struct obd_device *obddev) obddev->u.filter.fo_lastino = lastino; filp_close(file, 0); + rc = 0; out: pop_ctxt(&saved); @@ -360,7 +362,7 @@ static inline void filter_from_inode(struct obdo *oa, struct inode *inode) } #if 0 - else if (ext2obd_has_inline(inode)) { + else if (filter_has_inline(inode)) { CDEBUG(D_INFO, "copying inline from inode to obdo\n"); memcpy(oa->o_inline, inode->u.ext2_i.i_data, MIN(sizeof(inode->u.ext2_i.i_data),OBD_INLINESZ)); @@ -368,7 +370,7 @@ static inline void filter_from_inode(struct obdo *oa, struct inode *inode) oa->o_valid |= OBD_MD_FLINLINE; } - if (ext2obd_has_obdmd(inode)) { + if (filter_has_obdmd(inode)) { /* XXX this will change when we don't store the obdmd in data */ CDEBUG(D_INFO, "copying obdmd from inode to obdo\n"); memcpy(oa->o_obdmd, inode->u.ext2_i.i_data, @@ -438,6 +440,38 @@ static int filter_setattr(struct obd_conn *conn, struct obdo *oa) return rc; } +static int filter_open(struct obd_conn *conn, struct obdo *oa) +{ + struct inode *inode; + /* ENTRY; */ + + if (!gen_client(conn)) + RETURN(-EINVAL); + + if ( !(inode = filter_inode_from_obj(conn->oc_dev, + oa->o_id, oa->o_mode)) ) + RETURN(-ENOENT); + + return 0; +} /* filter_open */ + +static int filter_close(struct obd_conn *conn, struct obdo *oa) +{ + struct inode *inode; + /* ENTRY; */ + + if (!gen_client(conn)) + RETURN(-EINVAL); + + if ( !(inode = filter_inode_from_obj(conn->oc_dev, + oa->o_id, oa->o_mode)) ) + RETURN(-ENOENT); + + iput(inode); /* for the close */ + iput(inode); /* for this call */ + return 0; +} /* filter_close */ + static int filter_create (struct obd_conn* conn, struct obdo *oa) { char name[64]; @@ -609,7 +643,7 @@ static int filter_write(struct obd_conn *conn, struct obdo *oa, char *buf, } return err; -} /* ext2obd_write */ +} /* filter_write */ static int filter_pgcache_brw(int rw, struct obd_conn *conn, obd_count num_oa, @@ -732,100 +766,78 @@ struct inode *ioobj_to_inode(struct obd_conn *conn, struct obd_ioobj *o) return inode; } -int filter_preprw(int cmd, struct obd_conn *conn, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf *nb, - struct niobuf *res) +static int filter_preprw(int cmd, struct obd_conn *conn, + int objcount, struct obd_ioobj *obj, + int niocount, struct niobuf *nb, + struct niobuf *res) { - int i, j; - struct obd_ioobj *o; - struct niobuf *b; - struct niobuf *r; - struct inode *inode; - struct page *page; - int rc = 0; + struct obd_ioobj *o = obj; + struct niobuf *b = nb; + struct niobuf *r = res; + int i; ENTRY; memset(res, 0, sizeof(*res) * niocount); - for (i=0; i < objcount; i++) { - o = obj; - obj++; - for (j = 0 ; j < o->ioo_bufcnt ; j++) { - b = nb; - r = res; - nb++; - res++; - - inode = ioobj_to_inode(conn, o); - if (!inode) { - EXIT; - /* FIXME: we need to iput all of previous inodes */ - return -EINVAL; - } + for (i = 0; i < objcount; i++, o++) { + int j; + for (j = 0; j < o->ioo_bufcnt; j++, b++, r++) { + struct inode *inode = ioobj_to_inode(conn, o); + struct page *page; + + /* FIXME: we need to iput all inodes on error */ + if (!inode) + RETURN(-EINVAL); page = lustre_get_page(inode, b->offset >> PAGE_SHIFT); - if (IS_ERR(page)) { - EXIT; - return PTR_ERR(page); - } + if (IS_ERR(page)) + RETURN(PTR_ERR(page)); + if (cmd == OBD_BRW_WRITE) { - rc = lustre_prepare_page(0, PAGE_SIZE, page); - } - if (rc) { - CERROR("i %d j %d objcount %d bufcnt %d , rc %d, offset %Ld\n", i, j, objcount, o->ioo_bufcnt, rc, b->offset); + int rc = lustre_prepare_page(0, PAGE_SIZE,page); + if (rc) + CERROR("i %d j %d objcount %d bufcnt %d , rc %d, offset %Ld\n", i, j, objcount, o->ioo_bufcnt, rc, b->offset); } - - r->addr = (__u64)(unsigned long)page_address(page); + + r->addr = (__u64)(unsigned long)page_address(page); r->offset = b->offset; r->page = page; r->len = PAGE_SIZE; - /* r->flags */ } } return 0; } -int filter_commitrw(int cmd, struct obd_conn *conn, - int objcount, struct obd_ioobj *obj, - int niocount, struct niobuf *res) +static int filter_commitrw(int cmd, struct obd_conn *conn, + int objcount, struct obd_ioobj *obj, + int niocount, struct niobuf *res) { - int i, j; - int rc; - struct inode *inode; - struct obd_ioobj *o; - struct niobuf *r = NULL; + struct obd_ioobj *o = obj; + struct niobuf *r = res; + int i; ENTRY; - for (i=0; i < objcount; i++) { - o = obj; - obj++; + for (i = 0; i < objcount; i++, obj++) { + int j; + for (j = 0 ; j < o->ioo_bufcnt ; j++, r++) { + struct page *page = r->page; - for (j = 0 ; j < o->ioo_bufcnt ; j++) { - r = res; - if (!r) + if (!r->page) LBUG(); - res++; - if (!r) - LBUG(); + if (cmd == OBD_BRW_WRITE) { + int rc = lustre_commit_page(page, 0, PAGE_SIZE); - if (cmd == OBD_BRW_WRITE) - rc = lustre_commit_page(r->page, 0, PAGE_SIZE); - else { - lustre_put_page(r->page); - rc = 0; - } + /* FIXME: still need to iput the other inodes */ + if (rc) + RETURN(rc); + } else + lustre_put_page(page); - if (rc) { - EXIT; - return rc; - } - inode = ((struct page *)r->page)->mapping->host; - iput(inode); + iput(page->mapping->host); } } - return 0; + RETURN(0); } static int filter_statfs (struct obd_conn *conn, struct statfs * statfs) @@ -846,7 +858,7 @@ static int filter_statfs (struct obd_conn *conn, struct statfs * statfs) err = sb->s_op->statfs(sb, statfs); EXIT; return err; -} /* ext2obd_statfs */ +} /* filter_statfs */ static int filter_get_info(struct obd_conn *conn, obd_count keylen, @@ -904,6 +916,8 @@ struct obd_ops filter_obd_ops = { o_create: filter_create, o_setattr: filter_setattr, o_destroy: filter_destroy, + o_open: filter_open, + o_close: filter_close, o_read: filter_read, o_write: filter_write, o_brw: filter_pgcache_brw, @@ -911,10 +925,10 @@ struct obd_ops filter_obd_ops = { o_preprw: filter_preprw, o_commitrw: filter_commitrw #if 0 - o_preallocate: ext2obd_preallocate_inodes, - o_migrate: ext2obd_migrate, + o_preallocate: filter_preallocate_inodes, + o_migrate: filter_migrate, o_copy: gen_copy_data, - o_iterate: ext2obd_iterate + o_iterate: filter_iterate #endif };