4 * Copyright (C) 2001 Cluster File Systems, Inc.
6 * This code is issued under the GNU General Public License.
7 * See the file COPYING in this distribution
10 struct obdfs_inode_info {
12 struct list_head oi_inodes;
13 struct list_head oi_pages;
14 char oi_inline[OBD_INLINESZ];
17 struct obdfs_sb_info {
18 struct list_head osi_list; /* list of supers */
19 struct obd_conn osi_conn;
20 struct super_block *osi_super;
21 struct obd_device *osi_obd;
22 ino_t osi_rootino; /* number of root inode */
23 int osi_minor; /* minor of /dev/obdX */
24 struct list_head osi_inodes; /* list of dirty inodes */
25 unsigned long osi_cache_count;
26 struct semaphore osi_list_mutex;
30 static inline struct obdfs_inode_info *obdfs_i2info(struct inode *inode)
32 return (struct obdfs_inode_info *)&(inode->u.generic_ip);
35 static inline int obdfs_has_inline(struct inode *inode)
37 return (obdfs_i2info(inode)->oi_flags & OBD_FL_INLINEDATA);
40 static void inline obdfs_from_inode(struct obdo *oa, struct inode *inode)
42 struct obdfs_inode_info *oinfo = obdfs_i2info(inode);
44 CDEBUG(D_INFO, "src inode %ld, dst obdo %ld valid 0x%08x\n",
45 inode->i_ino, (long)oa->o_id, oa->o_valid);
46 obdo_from_inode(oa, inode);
47 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
48 CDEBUG(D_INODE, "copying device %x from inode to obdo\n",
50 *((obd_rdev *)oa->o_inline) = kdev_t_to_nr(inode->i_rdev);
51 oa->o_obdflags |= OBD_FL_INLINEDATA;
52 oa->o_valid |= OBD_MD_FLINLINE;
53 } else if (obdfs_has_inline(inode)) {
54 CDEBUG(D_INODE, "copying inline data from inode to obdo\n");
55 memcpy(oa->o_inline, oinfo->oi_inline, OBD_INLINESZ);
56 oa->o_obdflags |= OBD_FL_INLINEDATA;
57 oa->o_valid |= OBD_MD_FLINLINE;
59 } /* obdfs_from_inode */
61 static void inline obdfs_to_inode(struct inode *inode, struct obdo *oa)
63 struct obdfs_inode_info *oinfo = obdfs_i2info(inode);
65 CDEBUG(D_INFO, "src obdo %ld valid 0x%08x, dst inode %ld\n",
66 (long)oa->o_id, oa->o_valid, inode->i_ino);
68 obdo_to_inode(inode, oa);
70 if (obdo_has_inline(oa)) {
71 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
72 S_ISFIFO(inode->i_mode)) {
73 obd_rdev rdev = *((obd_rdev *)oa->o_inline);
75 "copying device %x from obdo to inode\n", rdev);
76 init_special_inode(inode, inode->i_mode, rdev);
78 CDEBUG(D_INFO, "copying inline from obdo to inode\n");
79 memcpy(oinfo->oi_inline, oa->o_inline, OBD_INLINESZ);
81 oinfo->oi_flags |= OBD_FL_INLINEDATA;
83 } /* obdfs_to_inode */
89 #warning "*** WARNING redefining OPS"
91 #define OPS(sb,op) ((struct obdfs_sb_info *)(& (sb)->u.generic_sbp))->osi_ops->o_ ## op
92 #define IOPS(inode,op) ((struct obdfs_sb_info *)(&(inode)->i_sb->u.generic_sbp))->osi_ops->o_ ## op
96 #warning "*** WARNING redefining ID"
98 #define ID(sb) (&((struct obdfs_sb_info *)( &(sb)->u.generic_sbp))->osi_conn)
99 #define IID(inode) (&((struct obdfs_sb_info *)( &(inode)->i_sb->u.generic_sbp))->osi_conn)
102 #define OBDFS_SUPER_MAGIC 0x4711