#define OBD_MD_FLGENER (0x2000UL)
#define OBD_MD_FLINLINE (0x4000UL)
#define OBD_MD_FLOBDMD (0x8000UL)
+#define OBD_MD_FLNOTOBD (~(OBD_MD_FLOBDMD | OBD_MD_FLOBDFLG))
/*
* ======== OBD Device Declarations ===========
static __inline__ struct obdo *obdo_alloc(void)
{
- struct obdo *res = NULL;
+ struct obdo *oa = NULL;
- res = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
- memset(res, 0, sizeof (*res));
+ oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
+ memset(oa, 0, sizeof (*oa));
- return res;
+ return oa;
}
static __inline__ void obdo_free(struct obdo *oa)
-static __inline__ struct obdo *obdo_fromid(struct obd_conn *conn, obd_id id)
+static __inline__ struct obdo *obdo_fromid(struct obd_conn *conn, obd_id id,
+ obd_flag valid)
{
- struct obdo *res = NULL;
+ struct obdo *oa;
int err;
- res = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
- if ( !res ) {
+ oa = obdo_alloc();
+ if ( !oa ) {
EXIT;
return ERR_PTR(-ENOMEM);
}
- memset(res, 0, sizeof(*res));
- res->o_id = id;
- res->o_valid = OBD_MD_FLALL;
- if ((err = OBP(conn->oc_dev, getattr)(conn, res))) {
- OBD_FREE(res, sizeof(*res));
+ memset(oa, 0, sizeof(*oa));
+ oa->o_id = id;
+ oa->o_valid = valid;
+ if ((err = OBP(conn->oc_dev, getattr)(conn, oa))) {
+ obdo_free(oa);
EXIT;
return ERR_PTR(err);
}
EXIT;
- return res;
+ return oa;
}
static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr)
dst->o_gid = src->o_gid;
if ( src->o_valid & OBD_MD_FLFLAGS )
dst->o_flags = src->o_flags;
+ /*
if ( src->o_valid & OBD_MD_FLOBDFLG )
dst->o_obdflags = src->o_obdflags;
+ */
if ( src->o_valid & OBD_MD_FLNLINK )
dst->o_nlink = src->o_nlink;
if ( src->o_valid & OBD_MD_FLGENER )
dst->o_generation = src->o_generation;
- if ( src->o_valid & OBD_MD_FLINLINE )
+ if ( src->o_valid & OBD_MD_FLINLINE &&
+ src->o_obdflags & OBD_FL_INLINEDATA) {
memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline));
- if ( src->o_valid & OBD_MD_FLOBDMD )
+ dst->o_obdflags |= OBD_FL_INLINEDATA;
+ }
+ if ( src->o_valid & OBD_MD_FLOBDMD &&
+ src->o_obdflags & OBD_FL_OBDMDEXISTS) {
memcpy(dst->o_obdmd, src->o_obdmd, sizeof(src->o_obdmd));
+ dst->o_obdflags |= OBD_FL_OBDMDEXISTS;
+ }
dst->o_valid |= src->o_valid;
}
/* ext2_obd.c */
extern struct obd_ops ext2_obd_ops;
-inline long ext2_block_map (struct inode * inode, long block);
/* balloc.c */
int ext2_new_block (const struct inode * inode, unsigned long goal,
unsigned long ext2_count_free(struct buffer_head * map, unsigned int numchars);
/* fsync.c */
-extern int obd_sync_file(struct file * file, struct dentry *dentry);
+int ext2_sync_file(struct file * file, struct dentry *dentry);
/* ialloc.c */
-extern void ext2_free_inode (struct inode * inode);
-extern struct inode * ext2_new_inode (const struct inode * dir, int mode,
+void ext2_free_inode (struct inode * inode);
+struct inode * ext2_new_inode (const struct inode * dir, int mode,
int * err);
-extern unsigned long ext2_count_free_inodes (struct super_block * sb);
-extern void ext2_check_inodes_bitmap (struct super_block * sb);
-extern int load_inode_bitmap (struct super_block * sb,
+unsigned long ext2_count_free_inodes (struct super_block * sb);
+void ext2_check_inodes_bitmap (struct super_block * sb);
+int load_inode_bitmap (struct super_block * sb,
unsigned int block_group);
/* inode.c */
-void obd_read_inode (struct inode * inode);
-void obd_write_inode (struct inode * inode);
-void obd_put_inode (struct inode * inode);
-void obd_delete_inode (struct inode * inode);
-void obd_discard_prealloc_blocks (struct inode * inode);
-int obd_sync_inode (struct inode *inode);
-struct buffer_head * obd_bread (struct inode * inode, int block,
- int create, int *err);
-struct buffer_head * obd_getblk (struct inode * inode, long block,
- int create, int * err);
+inline long ext2_block_map (struct inode * inode, long block);
/* super.c */
return (OBDFS_INFO(inode)->oi_flags & OBD_FL_INLINEDATA);
}
-static inline int obdfs_has_obdmd(struct inode *inode)
+static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
{
- return (OBDFS_INFO(inode)->oi_flags & OBD_FL_OBDMDEXISTS);
-}
+ struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
+
+ CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
+ obdo_from_inode(oa, inode);
+ if (obdfs_has_inline(inode)) {
+ CDEBUG(D_INODE, "inode has inline data\n");
+ memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
+ oa->o_obdflags |= OBD_FL_INLINEDATA;
+ oa->o_valid |= OBD_MD_FLINLINE;
+ }
+} /* obdfs_from_inode */
+
+static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
+{
+ struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
+
+ CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
+ obdo_to_inode(inode, oa);
+ if (obdo_has_inline(oa)) {
+ CDEBUG(D_INODE, "obdo has inline data\n");
+ memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
+ oinfo->oi_flags |= OBD_FL_INLINEDATA;
+ }
+} /* obdfs_to_inode */
#define NOLOCK 0
#define LOCKED 1
int err;
ENTRY;
- obdo = obdo_fromid(IID(inode), inode->i_ino);
+ obdo = obdo_fromid(IID(inode), inode->i_ino, OBD_MD_FLNOTOBD);
if ( IS_ERR(obdo) ) {
EXIT;
return PTR_ERR(obdo);
EXIT;
} /* obdfs_put_super */
-void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
-{
- struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
-
- CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
- obdo_from_inode(oa, inode);
- if (obdfs_has_inline(inode)) {
- CDEBUG(D_INODE, "inode has inline data\n");
- memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
- oa->o_obdflags |= OBD_FL_INLINEDATA;
- oa->o_valid |= OBD_MD_FLINLINE;
- }
- if (obdfs_has_obdmd(inode)) {
- CDEBUG(D_INODE, "inode %ld has obdmd data\n");
- oa->o_obdflags |= OBD_FL_OBDMDEXISTS;
- }
-} /* obdfs_from_inode */
-
-void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
-{
- struct obdfs_inode_info *oinfo = OBDFS_INFO(inode);
-
- CDEBUG(D_INODE, "inode %ld (%p)\n", inode->i_ino, inode);
- obdo_to_inode(inode, oa);
- if (obdo_has_inline(oa)) {
- CDEBUG(D_INODE, "obdo has inline data\n");
- memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
- oinfo->oi_flags |= OBD_FL_INLINEDATA;
- }
- if (obdo_has_obdmd(oa)) {
- CDEBUG(D_INODE, "obdo has obdmd data\n");
- oinfo->oi_flags |= OBD_FL_OBDMDEXISTS;
- }
-} /* obdfs_to_inode */
-
/* all filling in of inodes postponed until lookup */
void obdfs_read_inode(struct inode *inode)
{
struct obdo *oa;
- int err;
ENTRY;
- oa = obdo_alloc();
- if (!oa) {
- printk("obdfs_read_inode: obdo_alloc failed\n");
+ oa = obdo_fromid(IID(inode), inode->i_ino, OBD_MD_FLNOTOBD);
+ if ( IS_ERR(oa) ) {
+ printk("obdfs_read_inode: obdo_fromid failed\n");
EXIT;
- return;
- }
- oa->o_valid = ~OBD_MD_FLOBDMD;
- oa->o_id = inode->i_ino;
-
- INIT_LIST_HEAD(&OBDFS_INFO(inode)->oi_pages);
-
- err = IOPS(inode, getattr)(IID(inode), oa);
- if ( err ) {
- printk("obdfs_read_inode: obd_getattr fails (%d)\n", err);
- obdo_free(oa);
- EXIT;
- return;
+ return /* PTR_ERR(oa) */;
}
ODEBUG(oa);
inode->i_op = &obdfs_symlink_inode_operations;
else
init_special_inode(inode, inode->i_mode,
+ /* XXX need to fill in the ext2 side */
((long *)OBDFS_INFO(inode)->oi_inline)[0]);
EXIT;
return;
}
- oa->o_valid = ~OBD_MD_FLOBDMD;
+ oa->o_valid = OBD_MD_FLNOTOBD;
obdfs_from_inode(oa, inode);
err = IOPS(inode, setattr)(IID(inode), oa);
ENTRY;
oa = obdo_alloc();
- oa->o_valid = ~OBD_MD_FLOBDMD;
+ if ( !oa ) {
+ printk("obdfs_delete_inode: obdo_alloc failed\n");
+ return;
+ }
+ oa->o_valid = OBD_MD_FLNOTOBD;
obdfs_from_inode(oa, inode);
err = IOPS(inode, destroy)(IID(inode), oa);