Whamcloud - gitweb
Add separate file for MDS filesystem interaction routines.
[fs/lustre-release.git] / lustre / patches / patch-2.4.18
1 --- linux-2.4.17/kernel/ksyms.c.lustre  Fri Feb 22 15:26:38 2002
2 +++ linux-2.4.17/kernel/ksyms.c Fri Feb 22 15:27:44 2002
3 @@ -282,6 +282,11 @@
4  EXPORT_SYMBOL(lock_may_write);
5  EXPORT_SYMBOL(dcache_readdir);
6  
7 +/* lustre */
8 +EXPORT_SYMBOL(pagecache_lock);
9 +EXPORT_SYMBOL(do_kern_mount);
10 +
11 +
12  /* for stackable file systems (lofs, wrapfs, cryptfs, etc.) */
13  EXPORT_SYMBOL(default_llseek);
14  EXPORT_SYMBOL(dentry_open);
15 --- linux-2.4.18/include/linux/errno.h  Fri Feb  9 23:46:13 2001
16 +++ linux-2.4.18ea/include/linux/errno.h        Sun Mar 24 23:39:31 2002
17 @@ -21,6 +21,10 @@
18  #define EBADTYPE       527     /* Type not supported by server */
19  #define EJUKEBOX       528     /* Request initiated, but will not complete before timeout */
20  
21 +/* Defined for extended attributes */
22 +#define ENOATTR ENODATA                /* No such attribute */
23 +#define ENOTSUP EOPNOTSUPP     /* Operation not supported */
24 +
25  #endif
26  
27  #endif
28 --- linux-2.4.17/include/linux/fs.h.lustre      Fri Feb 22 15:27:53 2002
29 +++ linux-2.4.17/include/linux/fs.h     Fri Feb 22 15:28:52 2002
30 @@ -853,6 +865,10 @@
31         int (*revalidate) (struct dentry *);
32         int (*setattr) (struct dentry *, struct iattr *);
33         int (*getattr) (struct dentry *, struct iattr *);
34 +       int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
35 +       ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
36 +       ssize_t (*listxattr) (struct dentry *, char *, size_t);
37 +       int (*removexattr) (struct dentry *, const char *);
38  };
39  
40  struct seq_file;
41 @@ -983,7 +984,7 @@
42  extern struct vfsmount *kern_mount(struct file_system_type *);
43  extern int may_umount(struct vfsmount *);
44  extern long do_mount(char *, char *, char *, unsigned long, void *);
45 -
46 +struct vfsmount *do_kern_mount(char *type, int flags, char *name, void *data);
47  #define kern_umount mntput
48  
49  extern int vfs_statfs(struct super_block *, struct statfs *);
50 diff -Nur linux-2.4.18/include/linux/limits.h linux-2.4.18ea/include/linux/limits.h
51 --- linux-2.4.18/include/linux/limits.h Sun Feb 24 04:42:59 2002
52 +++ linux-2.4.18ea/include/linux/limits.h       Sun Feb 24 04:34:48 2002
53 @@ -13,6 +13,9 @@
54  #define NAME_MAX         255   /* # chars in a file name */
55  #define PATH_MAX        4096   /* # chars in a path name including nul */
56  #define PIPE_BUF        4096   /* # bytes in atomic write to a pipe */
57 +#define XATTR_NAME_MAX   255   /* # chars in an extended attribute name */
58 +#define XATTR_SIZE_MAX 65536   /* size of an extended attribute value (64k) */
59 +#define XATTR_LIST_MAX 65536   /* size of extended attribute namelist (64k) */
60  
61  #define RTSIG_MAX        32
62  
63 --- linux-2.4.17/fs/ext3/Makefile.orig  Fri Dec 21 10:41:55 2001
64 +++ linux-2.4.17/fs/ext3/Makefile       Fri Mar 22 11:00:58 2002
65 @@ -8,6 +8,8 @@
66  # Note 2! The CFLAGS definitions are now in the main makefile...
67  
68  O_TARGET := ext3.o
69 +
70 +export-objs := super.o
71  
72  obj-y    := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
73                 ioctl.o namei.o super.o symlink.o
74 --- linux-2.4.17/fs/ext3/super.c.orig   Fri Dec 21 10:41:55 2001
75 +++ linux-2.4.17/fs/ext3/super.c        Fri Mar 22 11:00:41 2002
76 @@ -1742,7 +1742,7 @@
77         unregister_filesystem(&ext3_fs_type);
78  }
79  
80 -EXPORT_NO_SYMBOLS;
81 +EXPORT_SYMBOL(ext3_bread);
82  
83  MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
84  MODULE_DESCRIPTION("Second Extended Filesystem with journaling extensions");
85 --- lum/include/linux/blkdev.h.orig     Thu Mar 28 11:40:24 2002
86 +++ lum/include/linux/blkdev.h  Thu Mar 28 23:38:46 2002
87 @@ -228,4 +228,8 @@
88         return retval;
89  }
90  
91 +#define CONFIG_DEV_RDONLY
92 +void dev_set_rdonly(kdev_t, int);
93 +int dev_check_rdonly(kdev_t);
94 +void dev_clear_rdonly(int);
95  #endif
96 --- lum/drivers/block/blkpg.c.orig      Sun Nov 11 11:20:21 2001
97 +++ lum/drivers/block/blkpg.c   Thu Mar 28 16:30:41 2002
98 @@ -294,3 +294,38 @@
99  }
100  
101  EXPORT_SYMBOL(blk_ioctl);
102 +
103 +#define NUM_DEV_NO_WRITE 16
104 +static int dev_no_write[NUM_DEV_NO_WRITE];
105 +
106 +/*
107 + * Debug code for turning block devices "read-only" (will discard writes
108 + * silently).  This is for filesystem crash/recovery testing.
109 + */
110 +void dev_set_rdonly(kdev_t dev, int no_write)
111 +{
112 +       if (dev) {
113 +               printk(KERN_WARNING "Turning device %s read-only\n", 
114 +                      bdevname(dev));
115 +               dev_no_write[no_write] = 0xdead0000 + dev;
116 +       }
117 +}
118 +
119 +int dev_check_rdonly(kdev_t dev) {
120 +       int i;
121 +
122 +       for (i = 0; i < NUM_DEV_NO_WRITE; i++) {
123 +               if ((dev_no_write[i] & 0xffff0000) == 0xdead0000 &&
124 +                   dev == (dev_no_write[i] & 0xffff))
125 +                       return 1;
126 +       }
127 +       return 0;
128 +}
129 +
130 +void dev_clear_rdonly(int no_write) {
131 +       dev_no_write[no_write] = 0;
132 +}
133 +
134 +EXPORT_SYMBOL(dev_set_rdonly);
135 +EXPORT_SYMBOL(dev_check_rdonly);
136 +EXPORT_SYMBOL(dev_clear_rdonly);
137 --- lum/drivers/block/loop.c.orig       Fri Dec 21 10:41:53 2001
138 +++ lum/drivers/block/loop.c    Thu Mar 28 23:39:25 2002
139 @@ -471,6 +475,11 @@
140         spin_unlock_irq(&lo->lo_lock);
141  
142         if (rw == WRITE) {
143 +#ifdef CONFIG_DEV_RDONLY
144 +               if (dev_check_rdonly(rbh->b_rdev))
145 +                       goto err;
146 +#endif
147 +
148                 if (lo->lo_flags & LO_FLAGS_READ_ONLY)
149                         goto err;
150         } else if (rw == READA) {
151 --- lum/drivers/ide/ide-disk.c.orig     Fri Dec 21 10:41:54 2001
152 +++ lum/drivers/ide/ide-disk.c  Thu Mar 28 23:38:41 2002
153 @@ -367,6 +367,12 @@
154   */
155  static ide_startstop_t do_rw_disk (ide_drive_t *drive, struct request *rq, unsigned long block)
156  {
157 +#ifdef CONFIG_DEV_RDONLY
158 +       if (rq->cmd == WRITE && dev_check_rdonly(rq->rq_dev)) {
159 +               ide_end_request(1, HWGROUP(drive));
160 +               return ide_stopped;
161 +       }
162 +#endif
163         if (IDE_CONTROL_REG)
164                 OUT_BYTE(drive->ctl,IDE_CONTROL_REG);
165         OUT_BYTE(0x00, IDE_FEATURE_REG);
166 --- lum/include/linux/jbd.h.orig        Tue Apr 16 14:27:25 2002
167 +++ lum/include/linux/jbd.h     Wed Apr 24 05:19:00 2002
168 @@ -249,6 +249,13 @@
169         return bh->b_private;
170  }
171  
172 +#define HAVE_JOURNAL_CALLBACK_STATUS
173 +struct journal_callback {
174 +       struct list_head jcb_list;
175 +       void (*jcb_func)(void *cb_data, int error);
176 +       /* user data goes here */
177 +};
178 +
179  struct jbd_revoke_table_s;
180  
181  /* The handle_t type represents a single atomic update being performed
182 @@ -279,6 +285,12 @@
183            operations */
184         int                     h_err;
185  
186 +       /* List of application registered callbacks for this handle.
187 +        * The function(s) will be called after the transaction that
188 +        * this handle is part of has been committed to disk.
189 +        */
190 +       struct list_head        h_jcb;
191 +
192         /* Flags */
193         unsigned int    h_sync:         1;      /* sync-on-close */
194         unsigned int    h_jdata:        1;      /* force data journaling */
195 @@ -398,6 +410,10 @@
196  
197         /* How many handles used this transaction? */
198         int t_handle_count;
199 +
200 +       /* List of registered callback functions for this transaction.
201 +        * Called when the transaction is committed. */
202 +       struct list_head        t_jcb;
203  };
204  
205  
206 @@ -646,6 +662,8 @@
207  extern int      journal_try_to_free_buffers(journal_t *, struct page *, int);
208  extern int      journal_stop(handle_t *);
209  extern int      journal_flush (journal_t *);
210 +extern void     journal_callback_set(handle_t *handle, void (*fn)(void *, int),
211 +                                     void *cb_data);
212  
213  extern void     journal_lock_updates (journal_t *);
214  extern void     journal_unlock_updates (journal_t *);
215 --- lum/fs/jbd/commit.c.orig    Fri Apr 12 10:27:52 2002
216 +++ lum/fs/jbd/commit.c Thu May 23 16:53:16 2002
217 @@ -475,7 +475,7 @@
218             transaction's t_log_list queue, and metadata buffers are on
219             the t_iobuf_list queue.
220  
221 -          Wait for the transactions in reverse order.  That way we are
222 +          Wait for the buffers in reverse order.  That way we are
223            less likely to be woken up until all IOs have completed, and
224            so we incur less scheduling load.
225         */
226 @@ -566,8 +566,10 @@
227  
228         jbd_debug(3, "JBD: commit phase 6\n");
229  
230 -       if (is_journal_aborted(journal))
231 +       if (is_journal_aborted(journal)) {
232 +               unlock_journal(journal);
233                 goto skip_commit;
234 +       }
235  
236         /* Done it all: now write the commit record.  We should have
237          * cleaned up our previous buffers by now, so if we are in abort
238 @@ -577,9 +579,10 @@
239         descriptor = journal_get_descriptor_buffer(journal);
240         if (!descriptor) {
241                 __journal_abort_hard(journal);
242 +               unlock_journal(journal);
243                 goto skip_commit;
244         }
245 -       
246 +
247         /* AKPM: buglet - add `i' to tmp! */
248         for (i = 0; i < jh2bh(descriptor)->b_size; i += 512) {
249                 journal_header_t *tmp =
250 @@ -600,7 +603,6 @@
251                 put_bh(bh);             /* One for getblk() */
252                 journal_unlock_journal_head(descriptor);
253         }
254 -       lock_journal(journal);
255  
256         /* End of a transaction!  Finally, we can do checkpoint
257             processing: any buffers committed as a result of this
258 @@ -609,6 +611,25 @@
259  
260  skip_commit:
261  
262 +       /* Call any callbacks that had been registered for handles in this
263 +        * transaction.  It is up to the callback to free any allocated
264 +        * memory.
265 +        */
266 +       if (!list_empty(&commit_transaction->t_jcb)) {
267 +               struct list_head *p, *n;
268 +               int error = is_journal_aborted(journal);
269 +
270 +               list_for_each_safe(p, n, &commit_transaction->t_jcb) {
271 +                       struct journal_callback *jcb;
272 +
273 +                       jcb = list_entry(p, struct journal_callback, jcb_list);
274 +                       list_del(p);
275 +                       jcb->jcb_func(jcb, error);
276 +               }
277 +       }
278 +
279 +       lock_journal(journal);
280 +
281         jbd_debug(3, "JBD: commit phase 7\n");
282  
283         J_ASSERT(commit_transaction->t_sync_datalist == NULL);
284 --- lum/fs/jbd/journal.c.orig   Fri Apr 12 10:27:52 2002
285 +++ lum/fs/jbd/journal.c        Wed Apr 24 05:18:49 2002
286 @@ -58,6 +58,7 @@
287  #endif
288  EXPORT_SYMBOL(journal_flush);
289  EXPORT_SYMBOL(journal_revoke);
290 +EXPORT_SYMBOL(journal_callback_set);
291  
292  EXPORT_SYMBOL(journal_init_dev);
293  EXPORT_SYMBOL(journal_init_inode);
294 --- lum/fs/jbd/transaction.c.orig       Fri Apr 12 10:27:52 2002
295 +++ lum/fs/jbd/transaction.c    Wed Apr 24 05:31:14 2002
296 @@ -57,6 +57,7 @@
297         transaction->t_state = T_RUNNING;
298         transaction->t_tid = journal->j_transaction_sequence++;
299         transaction->t_expires = jiffies + journal->j_commit_interval;
300 +       INIT_LIST_HEAD(&transaction->t_jcb);
301  
302         /* Set up the commit timer for the new transaction. */
303         J_ASSERT (!journal->j_commit_timer_active);
304 @@ -201,6 +202,20 @@
305         return 0;
306  }
307  
308 +/* Allocate a new handle.  This should probably be in a slab... */
309 +static handle_t *get_handle(int nblocks)
310 +{
311 +       handle_t *handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS);
312 +       if (!handle)
313 +               return NULL;
314 +       memset(handle, 0, sizeof (handle_t));
315 +       handle->h_buffer_credits = nblocks;
316 +       handle->h_ref = 1;
317 +       INIT_LIST_HEAD(&handle->h_jcb);
318 +
319 +       return handle;
320 +}
321 +
322  /*
323   * Obtain a new handle.  
324   *
325 @@ -227,14 +242,11 @@
326                 handle->h_ref++;
327                 return handle;
328         }
329 -       
330 -       handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS);
331 +
332 +       handle = get_handle(nblocks);
333         if (!handle)
334                 return ERR_PTR(-ENOMEM);
335 -       memset (handle, 0, sizeof (handle_t));
336  
337 -       handle->h_buffer_credits = nblocks;
338 -       handle->h_ref = 1;
339         current->journal_info = handle;
340  
341         err = start_this_handle(journal, handle);
342 @@ -333,14 +345,11 @@
343         
344         if (is_journal_aborted(journal))
345                 return ERR_PTR(-EIO);
346 -       
347 -       handle = jbd_kmalloc(sizeof (handle_t), GFP_NOFS);
348 +
349 +       handle = get_handle(nblocks);
350         if (!handle)
351                 return ERR_PTR(-ENOMEM);
352 -       memset (handle, 0, sizeof (handle_t));
353  
354 -       handle->h_buffer_credits = nblocks;
355 -       handle->h_ref = 1;
356         current->journal_info = handle;
357  
358         err = try_start_this_handle(journal, handle);
359 @@ -1328,6 +1337,29 @@
360  #endif
361  
362  /*
363 + * Register a callback function for this handle.  The function will be
364 + * called when the transaction that this handle is part of has been
365 + * committed to disk with the original callback data struct and the
366 + * error status of the journal as parameters.  There is no guarantee of
367 + * ordering between handles within a single transaction, nor between
368 + * callbacks registered on the same handle.
369 + *
370 + * The caller is responsible for allocating the journal_callback struct.
371 + * This is to allow the caller to add as much extra data to the callback
372 + * as needed, but reduce the overhead of multiple allocations.  The caller
373 + * allocated struct must start with a struct journal_callback at offset 0,
374 + * and has the caller-specific data afterwards.
375 + */
376 +void journal_callback_set(handle_t *handle, void (*func)(void *, int),
377 +                         void *cb_data)
378 +{
379 +       struct journal_callback *jcb = cb_data;
380 +
381 +       list_add(&jcb->jcb_list, &handle->h_jcb);
382 +       jcb->jcb_func = func;
383 +}
384 +
385 +/*
386   * All done for a particular handle.
387   *
388   * There is not much action needed here.  We just return any remaining
389 @@ -1393,7 +1423,10 @@
390                         wake_up(&journal->j_wait_transaction_locked);
391         }
392  
393 -       /* 
394 +       /* Move callbacks from the handle to the transaction. */
395 +       list_splice(&handle->h_jcb, &transaction->t_jcb);
396 +
397 +       /*
398          * If the handle is marked SYNC, we need to set another commit
399          * going!  We also want to force a commit if the current
400          * transaction is occupying too much of the log, or if the