Whamcloud - gitweb
Merge b_md into HEAD
[fs/lustre-release.git] / lustre / extN / extN-wantedi.diff
1 --- lustre/extN-clean/namei.c   2002-12-30 05:56:09.000000000 -0500
2 +++ lustre/extN/namei.c 2002-12-30 06:29:39.000000000 -0500
3 @@ -1224,7 +1224,8 @@
4         if (IS_SYNC(dir))
5                 handle->h_sync = 1;
6  
7 -       inode = extN_new_inode (handle, dir, mode);
8 +       inode = extN_new_inode (handle, dir, mode,
9 +                               (unsigned long)dentry->d_fsdata);
10         err = PTR_ERR(inode);
11         if (!IS_ERR(inode)) {
12                 inode->i_op = &extN_file_inode_operations;
13 @@ -1254,7 +1254,8 @@
14         if (IS_SYNC(dir))
15                 handle->h_sync = 1;
16  
17 -       inode = extN_new_inode (handle, dir, mode);
18 +       inode = extN_new_inode (handle, dir, mode,
19 +                               (unsigned long)dentry->d_fsdata);
20         err = PTR_ERR(inode);
21         if (!IS_ERR(inode)) {
22                 init_special_inode(inode, mode, rdev);
23 @@ -1286,7 +1286,8 @@
24         if (IS_SYNC(dir))
25                 handle->h_sync = 1;
26  
27 -       inode = extN_new_inode (handle, dir, S_IFDIR | mode);
28 +       inode = extN_new_inode (handle, dir, S_IFDIR | mode,
29 +                               (unsigned long)dentry->d_fsdata);
30         err = PTR_ERR(inode);
31         if (IS_ERR(inode))
32                 goto out_stop;
33 @@ -1680,7 +1681,8 @@
34         if (IS_SYNC(dir))
35                 handle->h_sync = 1;
36  
37 -       inode = extN_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
38 +       inode = extN_new_inode (handle, dir, S_IFLNK|S_IRWXUGO,
39 +                               (unsigned long)dentry->d_fsdata);
40         err = PTR_ERR(inode);
41         if (IS_ERR(inode))
42                 goto out_stop;
43 --- lustre/extN-clean/ialloc.c  2002-12-28 23:56:42.000000000 -0500
44 +++ lustre/extN/ialloc.c        2002-12-30 06:29:39.000000000 -0500
45 @@ -329,8 +329,8 @@
46   * For other inodes, search forward from the parent directory's block
47   * group to find a free inode.
48   */
49 -struct inode * extN_new_inode (handle_t *handle,
50 -                               const struct inode * dir, int mode)
51 +struct inode *extN_new_inode(handle_t *handle, const struct inode *dir,
52 +                            int mode, unsigned long goal)
53  {
54         struct super_block * sb;
55         struct buffer_head * bh;
56 @@ -360,6 +361,38 @@
57  
58         lock_super (sb);
59         es = sbi->s_es;
60 +
61 +       if (goal) {
62 +               i = (goal - 1) / EXTN_INODES_PER_GROUP(sb);
63 +               j = (goal - 1) % EXTN_INODES_PER_GROUP(sb);
64 +               gdp = extN_get_group_desc(sb, i, &bh2);
65 +
66 +               bitmap_nr = load_inode_bitmap (sb, i);
67 +               if (bitmap_nr < 0)
68 +                       goto fail;
69 +
70 +               bh = sbi->s_inode_bitmap[bitmap_nr];
71 +
72 +               BUFFER_TRACE(bh, "get_write_access");
73 +               err = extN_journal_get_write_access(handle, bh);
74 +               if (err) goto fail;
75 +
76 +               if (extN_set_bit(j, bh->b_data)) {
77 +                       printk(KERN_ERR "goal inode %lu unavailable\n", goal);
78 +                       /* Oh well, we tried. */
79 +                       goto repeat;
80 +               }
81 +
82 +               BUFFER_TRACE(bh, "call extN_journal_dirty_metadata");
83 +               err = extN_journal_dirty_metadata(handle, bh);
84 +               if (err) goto fail;
85 +
86 +               /* We've shortcircuited the allocation system successfully,
87 +                * now finish filling in the inode.
88 +                */
89 +               goto have_bit_and_group;
90 +       }
91 +
92  repeat:
93         gdp = NULL;
94         i = 0;
95 @@ -474,6 +509,7 @@
96                 }
97                 goto repeat;
98         }
99 +have_bit_and_group:
100         j += i * sbi->s_inodes_per_group + 1;
101         if (j < sbi->s_first_ino || j > le32_to_cpu(es->s_inodes_count)) {
102                 extN_error (sb, "extN_new_inode",
103 --- lustre/extN-clean/ioctl.c   2002-12-28 23:56:42.000000000 -0500
104 +++ lustre/extN/ioctl.c 2002-12-30 06:29:39.000000000 -0500
105 @@ -24,6 +24,31 @@
106         extN_debug ("cmd = %u, arg = %lu\n", cmd, arg);
107  
108         switch (cmd) {
109 +       case EXTN_IOC_CREATE_INUM: {
110 +               char name[32];
111 +               struct dentry *dchild, *dparent;
112 +               int rc = 0;
113 +
114 +               dparent = list_entry(inode->i_dentry.next, struct dentry,
115 +                                    d_alias);
116 +               snprintf(name, sizeof name, "%lu", arg);
117 +               dchild = lookup_one_len(name, dparent, strlen(name));
118 +               if (dchild->d_inode) {
119 +                       printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
120 +                              dparent->d_name.len, dparent->d_name.name, arg,
121 +                              dchild->d_inode->i_ino);
122 +                       rc = -EEXIST;
123 +               } else {
124 +                       dchild->d_fsdata = (void *)arg;
125 +                       rc = vfs_create(inode, dchild, 0644);
126 +                       if (rc)
127 +                               printk(KERN_ERR "vfs_create: %d\n", rc);
128 +                       else if (dchild->d_inode->i_ino != arg)
129 +                               rc = -EEXIST;
130 +               }
131 +               dput(dchild);
132 +               return rc;
133 +       }
134         case EXTN_IOC_GETFLAGS:
135                 flags = ei->i_flags & EXTN_FL_USER_VISIBLE;
136                 return put_user(flags, (int *) arg);
137 --- lustre/include/linux/extN_fs.h~     2002-12-30 06:01:43.000000000 -0500
138 +++ lustre/include/linux/extN_fs.h      2002-12-30 06:02:51.000000000 -0500
139 @@ -200,6 +200,7 @@
140  #define        EXTN_IOC_SETFLAGS               _IOW('f', 2, long)
141  #define        EXTN_IOC_GETVERSION             _IOR('f', 3, long)
142  #define        EXTN_IOC_SETVERSION             _IOW('f', 4, long)
143 +/* EXTN_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
144  #define        EXTN_IOC_GETVERSION_OLD         _IOR('v', 1, long)
145  #define        EXTN_IOC_SETVERSION_OLD         _IOW('v', 2, long)
146  #ifdef CONFIG_JBD_DEBUG
147 @@ -632,7 +633,8 @@
148  extern int extN_sync_file (struct file *, struct dentry *, int);
149  
150  /* ialloc.c */
151 -extern struct inode * extN_new_inode (handle_t *, const struct inode *, int);
152 +extern struct inode * extN_new_inode (handle_t *, const struct inode *, int,
153 +                                     unsigned long);
154  extern void extN_free_inode (handle_t *, struct inode *);
155  extern struct inode * extN_orphan_get (struct super_block *, ino_t);
156  extern unsigned long extN_count_free_inodes (struct super_block *);
157 @@ -714,4 +716,6 @@
158  
159  #endif /* __KERNEL__ */
160  
161 +#define EXTN_IOC_CREATE_INUM                   _IOW('f', 5, long)
162 +
163  #endif /* _LINUX_EXTN_FS_H */