Whamcloud - gitweb
b=22790 strip the .patch off of the dpatch name
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext3-nanosecond-2.6.22-vanilla.patch
1 Index: linux-2.6.18.8/fs/ext3/ialloc.c
2 ===================================================================
3 --- linux-2.6.18.8.orig/fs/ext3/ialloc.c        2007-06-20 18:54:59.000000000 +0200
4 +++ linux-2.6.18.8/fs/ext3/ialloc.c     2007-06-20 18:54:59.000000000 +0200
5 @@ -729,7 +729,8 @@ got:
6         /* This is the optimal IO size (for stat), not the fs block size */
7         inode->i_blksize = PAGE_SIZE;
8         inode->i_blocks = 0;
9 -       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
10 +       inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
11 +                                                      ext3_current_time(inode);
12  
13         memset(ei->i_data, 0, sizeof(ei->i_data));
14         ei->i_dir_start_lookup = 0;
15 @@ -761,9 +762,8 @@ got:
16         spin_unlock(&sbi->s_next_gen_lock);
17  
18         ei->i_state = EXT3_STATE_NEW;
19 -       ei->i_extra_isize =
20 -               (EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) ?
21 -               sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0;
22 +
23 +       ei->i_extra_isize = EXT3_SB(sb)->s_want_extra_isize;
24  
25         ret = inode;
26         if(DQUOT_ALLOC_INODE(inode)) {
27 Index: linux-2.6.18.8/fs/ext3/inode.c
28 ===================================================================
29 --- linux-2.6.18.8.orig/fs/ext3/inode.c 2007-06-20 18:54:52.000000000 +0200
30 +++ linux-2.6.18.8/fs/ext3/inode.c      2007-06-20 18:54:59.000000000 +0200
31 @@ -727,7 +727,7 @@ static int ext3_splice_branch(handle_t *
32  
33         /* We are done with atomic stuff, now do the rest of housekeeping */
34  
35 -       inode->i_ctime = CURRENT_TIME_SEC;
36 +       inode->i_ctime = ext3_current_time(inode);
37         ext3_mark_inode_dirty(handle, inode);
38  
39         /* had we spliced it onto indirect block? */
40 @@ -2375,7 +2375,7 @@ do_indirects:
41         ext3_discard_reservation(inode);
42  
43         mutex_unlock(&ei->truncate_mutex);
44 -       inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
45 +       inode->i_mtime = inode->i_ctime = ext3_current_time(inode);
46         ext3_mark_inode_dirty(handle, inode);
47  
48         /*
49 @@ -2611,10 +2611,6 @@ void ext3_read_inode(struct inode * inod
50         }
51         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
52         inode->i_size = le32_to_cpu(raw_inode->i_size);
53 -       inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
54 -       inode->i_ctime.tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime);
55 -       inode->i_mtime.tv_sec = (signed)le32_to_cpu(raw_inode->i_mtime);
56 -       inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0;
57  
58         ei->i_state = 0;
59         ei->i_dir_start_lookup = 0;
60 @@ -2689,6 +2685,11 @@ void ext3_read_inode(struct inode * inod
61         } else
62                 ei->i_extra_isize = 0;
63  
64 +       EXT3_INODE_GET_XTIME(i_ctime, inode, raw_inode);
65 +       EXT3_INODE_GET_XTIME(i_mtime, inode, raw_inode);
66 +       EXT3_INODE_GET_XTIME(i_atime, inode, raw_inode);
67 +       EXT3_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
68 +
69         if (S_ISREG(inode->i_mode)) {
70                 inode->i_op = &ext3_file_inode_operations;
71                 inode->i_fop = &ext3_file_operations;
72 @@ -2769,9 +2770,12 @@ static int ext3_do_update_inode(handle_t
73         }
74         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
75         raw_inode->i_size = cpu_to_le32(ei->i_disksize);
76 -       raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
77 -       raw_inode->i_ctime = cpu_to_le32(inode->i_ctime.tv_sec);
78 -       raw_inode->i_mtime = cpu_to_le32(inode->i_mtime.tv_sec);
79 +
80 +       EXT3_INODE_SET_XTIME(i_ctime, inode, raw_inode);
81 +       EXT3_INODE_SET_XTIME(i_mtime, inode, raw_inode);
82 +       EXT3_INODE_SET_XTIME(i_atime, inode, raw_inode);
83 +       EXT3_EINODE_SET_XTIME(i_crtime, ei, raw_inode);
84 +
85         raw_inode->i_blocks = cpu_to_le32(inode->i_blocks);
86         raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
87         raw_inode->i_flags = cpu_to_le32(ei->i_flags);
88 Index: linux-2.6.18.8/fs/ext3/ioctl.c
89 ===================================================================
90 --- linux-2.6.18.8.orig/fs/ext3/ioctl.c 2007-06-20 18:42:05.000000000 +0200
91 +++ linux-2.6.18.8/fs/ext3/ioctl.c      2007-06-20 18:54:59.000000000 +0200
92 @@ -120,7 +120,7 @@ int ext3_ioctl (struct inode * inode, st
93                 ei->i_flags = flags;
94  
95                 ext3_set_inode_flags(inode);
96 -               inode->i_ctime = CURRENT_TIME_SEC;
97 +               inode->i_ctime = ext3_current_time(inode);
98  
99                 err = ext3_mark_iloc_dirty(handle, inode, &iloc);
100  flags_err:
101 @@ -157,7 +157,7 @@ flags_err:
102                         return PTR_ERR(handle);
103                 err = ext3_reserve_inode_write(handle, inode, &iloc);
104                 if (err == 0) {
105 -                       inode->i_ctime = CURRENT_TIME_SEC;
106 +                       inode->i_ctime = ext3_current_time(inode);
107                         inode->i_generation = generation;
108                         err = ext3_mark_iloc_dirty(handle, inode, &iloc);
109                 }
110 Index: linux-2.6.18.8/fs/ext3/namei.c
111 ===================================================================
112 --- linux-2.6.18.8.orig/fs/ext3/namei.c 2007-06-20 18:54:53.000000000 +0200
113 +++ linux-2.6.18.8/fs/ext3/namei.c      2007-06-20 18:54:59.000000000 +0200
114 @@ -1287,7 +1287,7 @@ static int add_dirent_to_buf(handle_t *h
115          * happen is that the times are slightly out of date
116          * and/or different from the directory change time.
117          */
118 -       dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
119 +       dir->i_mtime = dir->i_ctime = ext3_current_time(dir);
120         ext3_update_dx_flag(dir);
121         dir->i_version++;
122         ext3_mark_inode_dirty(handle, dir);
123 @@ -2079,7 +2079,7 @@ static int ext3_rmdir (struct inode * di
124         inode->i_version++;
125         inode->i_nlink = 0;
126         ext3_orphan_add(handle, inode);
127 -       inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
128 +       inode->i_ctime = dir->i_ctime = dir->i_mtime = ext3_current_time(inode);
129         ext3_mark_inode_dirty(handle, inode);
130         ext3_dec_count(handle, dir);
131         ext3_update_dx_flag(dir);
132 @@ -2129,13 +2129,13 @@ static int ext3_unlink(struct inode * di
133         retval = ext3_delete_entry(handle, dir, de, bh);
134         if (retval)
135                 goto end_unlink;
136 -       dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
137 +       dir->i_ctime = dir->i_mtime = ext3_current_time(dir);
138         ext3_update_dx_flag(dir);
139         ext3_mark_inode_dirty(handle, dir);
140         ext3_dec_count(handle, inode);
141         if (!inode->i_nlink)
142                 ext3_orphan_add(handle, inode);
143 -       inode->i_ctime = dir->i_ctime;
144 +       inode->i_ctime = ext3_current_time(inode);
145         ext3_mark_inode_dirty(handle, inode);
146         retval = 0;
147  
148 @@ -2237,8 +2237,8 @@ retry:
149         if (IS_DIRSYNC(dir))
150                 handle->h_sync = 1;
151  
152 -       inode->i_ctime = CURRENT_TIME_SEC;
153 +       inode->i_ctime = ext3_current_time(inode);
154 -       inc_nlink(inode);
155 +       ext3_inc_count(handle, inode);
156         atomic_inc(&inode->i_count);
157  
158         err = ext3_add_link(handle, dentry, inode);
159 @@ -2340,7 +2340,7 @@ static int ext3_rename (struct inode * o
160          * Like most other Unix systems, set the ctime for inodes on a
161          * rename.
162          */
163 -       old_inode->i_ctime = CURRENT_TIME_SEC;
164 +       old_inode->i_ctime = ext3_current_time(old_inode);
165         ext3_mark_inode_dirty(handle, old_inode);
166  
167         /*
168 @@ -2373,9 +2373,9 @@ static int ext3_rename (struct inode * o
169  
170         if (new_inode) {
171                 ext3_dec_count(handle, new_inode);
172 -               new_inode->i_ctime = CURRENT_TIME_SEC;
173 +               new_inode->i_ctime = ext3_current_time(new_inode);
174         }
175 -       old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC;
176 +       old_dir->i_ctime = old_dir->i_mtime = ext3_current_time(old_dir);
177         ext3_update_dx_flag(old_dir);
178         if (dir_bh) {
179                 BUFFER_TRACE(dir_bh, "get_write_access");
180 Index: linux-2.6.18.8/fs/ext3/super.c
181 ===================================================================
182 --- linux-2.6.18.8.orig/fs/ext3/super.c 2007-06-20 18:54:59.000000000 +0200
183 +++ linux-2.6.18.8/fs/ext3/super.c      2007-06-20 18:54:59.000000000 +0200
184 @@ -1713,6 +1713,8 @@ static int ext3_fill_super (struct super
185                                 sbi->s_inode_size);
186                         goto failed_mount;
187                 }
188 +               if (sbi->s_inode_size > EXT3_GOOD_OLD_INODE_SIZE)
189 +                       sb->s_time_gran = 1 << (EXT3_EPOCH_BITS - 2);
190         }
191         sbi->s_frag_size = EXT3_MIN_FRAG_SIZE <<
192                                    le32_to_cpu(es->s_log_frag_size);
193 @@ -1917,6 +1919,32 @@ static int ext3_fill_super (struct super
194         }
195  
196         ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY);
197 +
198 +       /* determine the minimum size of new large inodes, if present */
199 +       if (sbi->s_inode_size > EXT3_GOOD_OLD_INODE_SIZE) {
200 +               sbi->s_want_extra_isize = sizeof(struct ext3_inode) -
201 +                                                    EXT3_GOOD_OLD_INODE_SIZE;
202 +               if (EXT3_HAS_RO_COMPAT_FEATURE(sb,
203 +                                      EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)) {
204 +                       if (sbi->s_want_extra_isize <
205 +                           le16_to_cpu(es->s_want_extra_isize))
206 +                               sbi->s_want_extra_isize =
207 +                                       le16_to_cpu(es->s_want_extra_isize);
208 +                       if (sbi->s_want_extra_isize <
209 +                           le16_to_cpu(es->s_min_extra_isize))
210 +                               sbi->s_want_extra_isize =
211 +                                       le16_to_cpu(es->s_min_extra_isize);
212 +               }
213 +       }
214 +       /* Check if enough inode space is available */
215 +       if (EXT3_GOOD_OLD_INODE_SIZE + sbi->s_want_extra_isize >
216 +                                                       sbi->s_inode_size) {
217 +               sbi->s_want_extra_isize = sizeof(struct ext3_inode) -
218 +                                                      EXT3_GOOD_OLD_INODE_SIZE;
219 +               printk(KERN_INFO "EXT3-fs: required extra inode space not"
220 +                       "available.\n");
221 +       }
222 +
223         /*
224          * akpm: core read_super() calls in here with the superblock locked.
225          * That deadlocks, because orphan cleanup needs to lock the superblock
226 Index: linux-2.6.18.8/fs/ext3/xattr.c
227 ===================================================================
228 --- linux-2.6.18.8.orig/fs/ext3/xattr.c 2007-06-20 18:54:52.000000000 +0200
229 +++ linux-2.6.18.8/fs/ext3/xattr.c      2007-06-20 18:54:59.000000000 +0200
230 @@ -1007,7 +1007,7 @@ ext3_xattr_set_handle(handle_t *handle, 
231         }
232         if (!error) {
233                 ext3_xattr_update_super_block(handle, inode->i_sb);
234 -               inode->i_ctime = CURRENT_TIME_SEC;
235 +               inode->i_ctime = ext3_current_time(inode);
236                 error = ext3_mark_iloc_dirty(handle, inode, &is.iloc);
237                 /*
238                  * The bh is consumed by ext3_mark_iloc_dirty, even with
239 Index: linux-2.6.18.8/include/linux/ext3_fs.h
240 ===================================================================
241 --- linux-2.6.18.8.orig/include/linux/ext3_fs.h 2007-06-20 18:54:59.000000000 +0200
242 +++ linux-2.6.18.8/include/linux/ext3_fs.h      2007-06-20 18:54:59.000000000 +0200
243 @@ -288,7 +288,7 @@ struct ext3_inode {
244         __le16  i_uid;          /* Low 16 bits of Owner Uid */
245         __le32  i_size;         /* Size in bytes */
246         __le32  i_atime;        /* Access time */
247 -       __le32  i_ctime;        /* Creation time */
248 +       __le32  i_ctime;        /* Inode Change time */
249         __le32  i_mtime;        /* Modification time */
250         __le32  i_dtime;        /* Deletion Time */
251         __le16  i_gid;          /* Low 16 bits of Group Id */
252 @@ -337,10 +337,73 @@ struct ext3_inode {
253         } osd2;                         /* OS dependent 2 */
254         __le16  i_extra_isize;
255         __le16  i_pad1;
256 +       __le32  i_ctime_extra;  /* extra Change time      (nsec << 2 | epoch) */
257 +       __le32  i_mtime_extra;  /* extra Modification time(nsec << 2 | epoch) */
258 +       __le32  i_atime_extra;  /* extra Access time      (nsec << 2 | epoch) */
259 +       __le32  i_crtime;       /* File Creation time */
260 +       __le32  i_crtime_extra; /* extra File Creation time (nsec << 2 | epoch) */
261  };
262  
263  #define i_size_high    i_dir_acl
264  
265 +#define EXT3_EPOCH_BITS 2
266 +#define EXT3_EPOCH_MASK ((1 << EXT3_EPOCH_BITS) - 1)
267 +#define EXT3_NSEC_MASK  (~0UL << EXT3_EPOCH_BITS)
268 +
269 +#define EXT3_FITS_IN_INODE(ext3_inode, einode, field)  \
270 +       ((offsetof(typeof(*ext3_inode), field) +        \
271 +         sizeof((ext3_inode)->field))                  \
272 +       <= (EXT3_GOOD_OLD_INODE_SIZE +                  \
273 +           (einode)->i_extra_isize))                   \
274 +
275 +static inline __le32 ext3_encode_extra_time(struct timespec *time)
276 +{
277 +       return cpu_to_le32((sizeof(time->tv_sec) > 4 ?
278 +                           time->tv_sec >> 32 : 0) |
279 +                           ((time->tv_nsec << 2) & EXT3_NSEC_MASK));
280 +}
281 +
282 +static inline void ext3_decode_extra_time(struct timespec *time, __le32 extra) {
283 +       if (sizeof(time->tv_sec) > 4)
284 +               time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT3_EPOCH_MASK)
285 +                               << 32;
286 +       time->tv_nsec = (le32_to_cpu(extra) & EXT3_NSEC_MASK) >> 2;
287 +}
288 +
289 +#define EXT3_INODE_SET_XTIME(xtime, inode, raw_inode)                         \
290 +do {                                                                          \
291 +       (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec);               \
292 +       if (EXT3_FITS_IN_INODE(raw_inode, EXT3_I(inode), xtime ## _extra))     \
293 +               (raw_inode)->xtime ## _extra =                                 \
294 +                               ext3_encode_extra_time(&(inode)->xtime);       \
295 +} while (0)
296 +
297 +#define EXT3_EINODE_SET_XTIME(xtime, einode, raw_inode)\
298 +do {                                                                          \
299 +       if (EXT3_FITS_IN_INODE(raw_inode, einode, xtime))                      \
300 +               (raw_inode)->xtime = cpu_to_le32((einode)->xtime.tv_sec);      \
301 +       if (EXT3_FITS_IN_INODE(raw_inode, einode, xtime ## _extra))            \
302 +               (raw_inode)->xtime ## _extra =                                 \
303 +                               ext3_encode_extra_time(&(einode)->xtime);      \
304 +} while (0)
305 +
306 +#define EXT3_INODE_GET_XTIME(xtime, inode, raw_inode)                         \
307 +do {                                                                          \
308 +       (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);               \
309 +       if (EXT3_FITS_IN_INODE(raw_inode, EXT3_I(inode), xtime ## _extra))     \
310 +               ext3_decode_extra_time(&(inode)->xtime,                        \
311 +                                      raw_inode->xtime ## _extra);            \
312 +} while (0)
313 +
314 +#define EXT3_EINODE_GET_XTIME(xtime, einode, raw_inode)                       \
315 +do {                                                                          \
316 +       if (EXT3_FITS_IN_INODE(raw_inode, einode, xtime))                      \
317 +               (einode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);      \
318 +       if (EXT3_FITS_IN_INODE(raw_inode, einode, xtime ## _extra))            \
319 +               ext3_decode_extra_time(&(einode)->xtime,                       \
320 +                                      raw_inode->xtime ## _extra);            \
321 +} while (0)
322 +
323  #if defined(__KERNEL__) || defined(__linux__)
324  #define i_reserved1    osd1.linux1.l_i_reserved1
325  #define i_frag         osd2.linux2.l_i_frag
326 @@ -520,11 +583,19 @@ struct ext3_super_block {
327         __le32  s_last_orphan;          /* start of list of inodes to delete */
328         __le32  s_hash_seed[4];         /* HTREE hash seed */
329         __u8    s_def_hash_version;     /* Default hash version to use */
330 -       __u8    s_reserved_char_pad;
331 -       __u16   s_reserved_word_pad;
332 +       __u8    s_jnl_backup_type;      /* Default type of journal backup */
333 +       __le16  s_desc_size;            /* Group desc. size: INCOMPAT_64BIT */
334         __le32  s_default_mount_opts;
335 -       __le32  s_first_meta_bg;        /* First metablock block group */
336 -       __u32   s_reserved[190];        /* Padding to the end of the block */
337 +       __le32  s_first_meta_bg;        /* First metablock block group */
338 +       __le32  s_mkfs_time;            /* When the filesystem was created */
339 +       __le32  s_jnl_blocks[17];       /* Backup of the journal inode */
340 +       __le32  s_blocks_count_hi;      /* Blocks count high 32 bits */
341 +       __le32  s_r_blocks_count_hi;    /* Reserved blocks count high 32 bits*/
342 +       __le32  s_free_blocks_count_hi; /* Free blocks count high 32 bits */
343 +       __le16  s_min_extra_isize;      /* All inodes have at least # bytes */
344 +       __le16  s_want_extra_isize;     /* New inodes should reserve # bytes */
345 +       __le32  s_flags;                /* Miscellaneous flags */
346 +       __u32   s_reserved[167];        /* Padding to the end of the block */
347  };
348  
349  #ifdef __KERNEL__
350 @@ -539,6 +610,13 @@ static inline struct ext3_inode_info *EX
351         return container_of(inode, struct ext3_inode_info, vfs_inode);
352  }
353  
354 +static inline struct timespec ext3_current_time(struct inode *inode)
355 +{
356 +       return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
357 +               current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
358 +}
359 +
360 +
361  static inline int ext3_valid_inum(struct super_block *sb, unsigned long ino)
362  {
363         return ino == EXT3_ROOT_INO ||
364 @@ -611,6 +689,8 @@ static inline int ext3_valid_inum(struct
365  #define EXT3_FEATURE_RO_COMPAT_BTREE_DIR       0x0004
366  #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM                0x0010
367  #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK       0x0020
368 +#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE     0x0040
369 +
370  
371  #define EXT3_FEATURE_INCOMPAT_COMPRESSION      0x0001
372  #define EXT3_FEATURE_INCOMPAT_FILETYPE         0x0002
373 @@ -628,6 +708,7 @@ static inline int ext3_valid_inum(struct
374                                          EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
375                                          EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
376                                          EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
377 +                                        EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE| \
378                                          EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
379  
380  /*
381 Index: linux-2.6.18.8/include/linux/ext3_fs_sb.h
382 ===================================================================
383 --- linux-2.6.18.8.orig/include/linux/ext3_fs_sb.h      2007-06-20 18:54:54.000000000 +0200
384 +++ linux-2.6.18.8/include/linux/ext3_fs_sb.h   2007-06-20 18:54:59.000000000 +0200
385 @@ -68,6 +68,9 @@ struct ext3_sb_info {
386         /* Last group used to allocate inode */
387         int s_last_alloc_group;
388  
389 +       /* New inodes should reserve # bytes */
390 +       unsigned int  s_want_extra_isize;
391 +
392         /* root of the per fs reservation window tree */
393         spinlock_t s_rsv_window_lock;
394         struct rb_root s_rsv_window_root;
395 Index: linux-2.6.18.8/include/linux/ext3_fs_i.h
396 ===================================================================
397 --- linux-2.6.18.8.orig/include/linux/ext3_fs_i.h       2007-06-20 18:54:57.000000000 +0200
398 +++ linux-2.6.18.8/include/linux/ext3_fs_i.h    2007-06-20 18:54:59.000000000 +0200
399 @@ -140,6 +140,8 @@ struct ext3_inode_info {
400         /* on-disk additional length */
401         __u16 i_extra_isize;
402  
403 +       struct timespec i_crtime;
404 +
405         /*
406          * truncate_mutex is for serialising ext3_truncate() against
407          * ext3_getblock().  In the 2.4 ext2 design, great chunks of inode's