Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / linux-2.6.9-ext3-sub-second-timestamp.patch
1 Index: linux-2.6.10/drivers/char/qtronix.c
2 ===================================================================
3 --- linux-2.6.10.orig/drivers/char/qtronix.c    2004-12-24 14:35:50.000000000 -0700
4 +++ linux-2.6.10/drivers/char/qtronix.c 2006-01-03 16:16:52.000000000 -0700
5 @@ -537,7 +537,7 @@
6                 i--;
7         }
8         if (count-i) {
9 -               file->f_dentry->d_inode->i_atime = CURRENT_TIME;
10 +               file->f_dentry->d_inode->i_atime = current_fs_time(inode->i_sb);
11                 return count-i;
12         }
13         if (signal_pending(current))
14 Index: linux-2.6.10/drivers/char/random.c
15 ===================================================================
16 --- linux-2.6.10.orig/drivers/char/random.c     2005-04-06 09:38:33.000000000 -0600
17 +++ linux-2.6.10/drivers/char/random.c  2006-01-03 16:16:52.000000000 -0700
18 @@ -1743,8 +1743,9 @@
19         if (p == buffer) {
20                 return (ssize_t)ret;
21         } else {
22 -               file->f_dentry->d_inode->i_mtime = CURRENT_TIME;
23 -               mark_inode_dirty(file->f_dentry->d_inode);
24 +               struct inode *inode = file->f_dentry->d_inode;
25 +               inode->i_mtime = current_fs_time(inode->i_sb);
26 +               mark_inode_dirty(inode);
27                 return (ssize_t)(p - buffer);
28         }
29  }
30 Index: linux-2.6.10/drivers/char/sonypi.c
31 ===================================================================
32 --- linux-2.6.10.orig/drivers/char/sonypi.c     2004-12-24 14:35:23.000000000 -0700
33 +++ linux-2.6.10/drivers/char/sonypi.c  2006-01-03 16:18:31.000000000 -0700
34 @@ -537,7 +537,8 @@
35         }
36  
37         if (ret > 0)
38 -               file->f_dentry->d_inode->i_atime = CURRENT_TIME;
39 +               struct inode *inode = file->f_dentry->d_inode;
40 +               inode->i_atime = current_fs_time(inode->i_sb);
41  
42         return ret;
43  }
44 Index: linux-2.6.10/drivers/char/tty_io.c
45 ===================================================================
46 --- linux-2.6.10.orig/drivers/char/tty_io.c     2005-04-06 09:38:33.000000000 -0600
47 +++ linux-2.6.10/drivers/char/tty_io.c  2006-01-03 16:16:52.000000000 -0700
48 @@ -1018,7 +1018,7 @@
49         tty_ldisc_deref(ld);
50         unlock_kernel();
51         if (i > 0)
52 -               inode->i_atime = CURRENT_TIME;
53 +               inode->i_atime = current_fs_time(inode->i_sb);
54         return i;
55  }
56  
57 @@ -1095,7 +1095,8 @@
58                 cond_resched();
59         }
60         if (written) {
61 -               file->f_dentry->d_inode->i_mtime = CURRENT_TIME;
62 +               struct inode *inode = file->f_dentry->d_inode;
63 +               inode->i_mtime = current_fs_time(inode->i_sb);
64                 ret = written;
65         }
66         up(&tty->atomic_write);
67 Index: linux-2.6.10/fs/attr.c
68 ===================================================================
69 --- linux-2.6.10.orig/fs/attr.c 2004-12-24 14:34:00.000000000 -0700
70 +++ linux-2.6.10/fs/attr.c      2006-01-03 16:16:52.000000000 -0700
71 @@ -14,6 +14,7 @@
72  #include <linux/fcntl.h>
73  #include <linux/quotaops.h>
74  #include <linux/security.h>
75 +#include <linux/time.h>
76  
77  /* Taken over from the old code... */
78  
79 @@ -87,11 +88,14 @@
80         if (ia_valid & ATTR_GID)
81                 inode->i_gid = attr->ia_gid;
82         if (ia_valid & ATTR_ATIME)
83 -               inode->i_atime = attr->ia_atime;
84 +               inode->i_atime = timespec_trunc(attr->ia_atime,
85 +                                               get_sb_time_gran(inode->i_sb));
86         if (ia_valid & ATTR_MTIME)
87 -               inode->i_mtime = attr->ia_mtime;
88 +               inode->i_mtime = timespec_trunc(attr->ia_mtime,
89 +                                               get_sb_time_gran(inode->i_sb));
90         if (ia_valid & ATTR_CTIME)
91 -               inode->i_ctime = attr->ia_ctime;
92 +               inode->i_ctime = timespec_trunc(attr->ia_ctime,
93 +                                               get_sb_time_gran(inode->i_sb));
94         if (ia_valid & ATTR_MODE) {
95                 umode_t mode = attr->ia_mode;
96  
97 @@ -131,14 +135,17 @@
98  int notify_change(struct dentry * dentry, struct iattr * attr)
99  {
100         struct inode *inode = dentry->d_inode;
101 -       mode_t mode = inode->i_mode;
102 +       mode_t mode;
103         int error;
104 -       struct timespec now = CURRENT_TIME;
105 +       struct timespec now;
106         unsigned int ia_valid = attr->ia_valid;
107  
108         if (!inode)
109                 BUG();
110  
111 +       mode = inode->i_mode;
112 +       now = current_fs_time(inode->i_sb);
113 +
114         attr->ia_ctime = now;
115         if (!(ia_valid & ATTR_ATIME_SET))
116                 attr->ia_atime = now;
117 Index: linux-2.6.10/fs/bad_inode.c
118 ===================================================================
119 --- linux-2.6.10.orig/fs/bad_inode.c    2004-12-24 14:35:50.000000000 -0700
120 +++ linux-2.6.10/fs/bad_inode.c 2006-01-03 16:16:52.000000000 -0700
121 @@ -105,7 +105,8 @@
122         remove_inode_hash(inode);
123  
124         inode->i_mode = S_IFREG;
125 -       inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
126 +       inode->i_atime = inode->i_mtime = inode->i_ctime = 
127 +               current_fs_time(inode->i_sb);
128         inode->i_op = &bad_inode_ops;   
129         inode->i_fop = &bad_file_ops;   
130  }
131 Index: linux-2.6.10/fs/binfmt_misc.c
132 ===================================================================
133 --- linux-2.6.10.orig/fs/binfmt_misc.c  2004-12-24 14:34:31.000000000 -0700
134 +++ linux-2.6.10/fs/binfmt_misc.c       2006-01-03 16:16:52.000000000 -0700
135 @@ -509,7 +509,8 @@
136                 inode->i_gid = 0;
137                 inode->i_blksize = PAGE_CACHE_SIZE;
138                 inode->i_blocks = 0;
139 -               inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
140 +               inode->i_atime = inode->i_mtime = inode->i_ctime =
141 +                       current_fs_time(inode->i_sb);
142         }
143         return inode;
144  }
145 Index: linux-2.6.10/fs/ext2/dir.c
146 ===================================================================
147 --- linux-2.6.10.orig/fs/ext2/dir.c     2004-12-24 14:34:58.000000000 -0700
148 +++ linux-2.6.10/fs/ext2/dir.c  2006-01-03 16:16:52.000000000 -0700
149 @@ -426,7 +426,7 @@
150         ext2_set_de_type (de, inode);
151         err = ext2_commit_chunk(page, from, to);
152         ext2_put_page(page);
153 -       dir->i_mtime = dir->i_ctime = CURRENT_TIME;
154 +       dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
155         EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
156         mark_inode_dirty(dir);
157  }
158 @@ -516,7 +516,7 @@
159         de->inode = cpu_to_le32(inode->i_ino);
160         ext2_set_de_type (de, inode);
161         err = ext2_commit_chunk(page, from, to);
162 -       dir->i_mtime = dir->i_ctime = CURRENT_TIME;
163 +       dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
164         EXT2_I(dir)->i_flags &= ~EXT2_BTREE_FL;
165         mark_inode_dirty(dir);
166         /* OFFSET_CACHE */
167 @@ -564,7 +564,7 @@
168                 pde->rec_len = cpu_to_le16(to-from);
169         dir->inode = 0;
170         err = ext2_commit_chunk(page, from, to);
171 -       inode->i_ctime = inode->i_mtime = CURRENT_TIME;
172 +       inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
173         EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
174         mark_inode_dirty(inode);
175  out:
176 Index: linux-2.6.10/fs/ext2/ialloc.c
177 ===================================================================
178 --- linux-2.6.10.orig/fs/ext2/ialloc.c  2004-12-24 14:34:47.000000000 -0700
179 +++ linux-2.6.10/fs/ext2/ialloc.c       2006-01-03 16:16:52.000000000 -0700
180 @@ -577,7 +577,7 @@
181         inode->i_ino = ino;
182         inode->i_blksize = PAGE_SIZE;   /* This is the optimal IO size (for stat), not the fs block size */
183         inode->i_blocks = 0;
184 -       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
185 +       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
186         memset(ei->i_data, 0, sizeof(ei->i_data));
187         ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
188         if (S_ISLNK(mode))
189 Index: linux-2.6.10/fs/ext2/inode.c
190 ===================================================================
191 --- linux-2.6.10.orig/fs/ext2/inode.c   2004-12-24 14:33:51.000000000 -0700
192 +++ linux-2.6.10/fs/ext2/inode.c        2006-01-03 16:16:52.000000000 -0700
193 @@ -493,7 +493,7 @@
194  
195         /* We are done with atomic stuff, now do the rest of housekeeping */
196  
197 -       inode->i_ctime = CURRENT_TIME;
198 +       inode->i_ctime = CURRENT_TIME_SEC;
199  
200         /* had we spliced it onto indirect block? */
201         if (where->bh)
202 @@ -953,7 +953,7 @@
203                 case EXT2_TIND_BLOCK:
204                         ;
205         }
206 -       inode->i_mtime = inode->i_ctime = CURRENT_TIME;
207 +       inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
208         if (inode_needs_sync(inode)) {
209                 sync_mapping_buffers(inode->i_mapping);
210                 ext2_sync_inode (inode);
211 Index: linux-2.6.10/fs/ext2/ioctl.c
212 ===================================================================
213 --- linux-2.6.10.orig/fs/ext2/ioctl.c   2004-12-24 14:35:49.000000000 -0700
214 +++ linux-2.6.10/fs/ext2/ioctl.c        2006-01-03 16:16:52.000000000 -0700
215 @@ -59,7 +59,7 @@
216                 ei->i_flags = flags;
217  
218                 ext2_set_inode_flags(inode);
219 -               inode->i_ctime = CURRENT_TIME;
220 +               inode->i_ctime = CURRENT_TIME_SEC;
221                 mark_inode_dirty(inode);
222                 return 0;
223         }
224 @@ -72,7 +72,7 @@
225                         return -EROFS;
226                 if (get_user(inode->i_generation, (int __user *) arg))
227                         return -EFAULT; 
228 -               inode->i_ctime = CURRENT_TIME;
229 +               inode->i_ctime = CURRENT_TIME_SEC;
230                 mark_inode_dirty(inode);
231                 return 0;
232         default:
233 Index: linux-2.6.10/fs/ext2/namei.c
234 ===================================================================
235 --- linux-2.6.10.orig/fs/ext2/namei.c   2004-12-24 14:35:25.000000000 -0700
236 +++ linux-2.6.10/fs/ext2/namei.c        2006-01-03 16:16:52.000000000 -0700
237 @@ -211,7 +211,7 @@
238         if (inode->i_nlink >= EXT2_LINK_MAX)
239                 return -EMLINK;
240  
241 -       inode->i_ctime = CURRENT_TIME;
242 +       inode->i_ctime = CURRENT_TIME_SEC;
243         ext2_inc_count(inode);
244         atomic_inc(&inode->i_count);
245  
246 @@ -337,7 +337,7 @@
247                         goto out_dir;
248                 ext2_inc_count(old_inode);
249                 ext2_set_link(new_dir, new_de, new_page, old_inode);
250 -               new_inode->i_ctime = CURRENT_TIME;
251 +               new_inode->i_ctime = CURRENT_TIME_SEC;
252                 if (dir_de)
253                         new_inode->i_nlink--;
254                 ext2_dec_count(new_inode);
255 @@ -362,7 +362,7 @@
256          * rename.
257          * ext2_dec_count() will mark the inode dirty.
258          */
259 -       old_inode->i_ctime = CURRENT_TIME;
260 +       old_inode->i_ctime = CURRENT_TIME_SEC;
261  
262         ext2_delete_entry (old_de, old_page);
263         ext2_dec_count(old_inode);
264 Index: linux-2.6.10/fs/ext2/super.c
265 ===================================================================
266 --- linux-2.6.10.orig/fs/ext2/super.c   2004-12-24 14:35:01.000000000 -0700
267 +++ linux-2.6.10/fs/ext2/super.c        2006-01-03 16:19:06.000000000 -0700
268 @@ -595,7 +595,7 @@
269         es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
270         sbi->s_es = es;
271         sb->s_magic = le16_to_cpu(es->s_magic);
272 -       sb->s_flags |= MS_ONE_SECOND;
273 +       set_sb_time_gran(sb, 1000000000U);
274  
275         if (sb->s_magic != EXT2_SUPER_MAGIC)
276                 goto cantfind_ext2;
277 Index: linux-2.6.10/fs/ext2/xattr.c
278 ===================================================================
279 --- linux-2.6.10.orig/fs/ext2/xattr.c   2005-04-06 09:38:35.000000000 -0600
280 +++ linux-2.6.10/fs/ext2/xattr.c        2006-01-03 16:16:52.000000000 -0700
281 @@ -702,7 +702,7 @@
282  
283         /* Update the inode. */
284         EXT2_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
285 -       inode->i_ctime = CURRENT_TIME;
286 +       inode->i_ctime = CURRENT_TIME_SEC;
287         if (IS_SYNC(inode)) {
288                 error = ext2_sync_inode (inode);
289                 if (error)
290 Index: linux-2.6.10/fs/ext3/ialloc.c
291 ===================================================================
292 --- linux-2.6.10.orig/fs/ext3/ialloc.c  2004-12-24 14:34:45.000000000 -0700
293 +++ linux-2.6.10/fs/ext3/ialloc.c       2006-01-03 16:16:52.000000000 -0700
294 @@ -558,7 +558,7 @@
295         /* This is the optimal IO size (for stat), not the fs block size */
296         inode->i_blksize = PAGE_SIZE;
297         inode->i_blocks = 0;
298 -       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
299 +       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
300  
301         memset(ei->i_data, 0, sizeof(ei->i_data));
302         ei->i_next_alloc_block = 0;
303 Index: linux-2.6.10/fs/ext3/inode.c
304 ===================================================================
305 --- linux-2.6.10.orig/fs/ext3/inode.c   2005-04-06 09:38:35.000000000 -0600
306 +++ linux-2.6.10/fs/ext3/inode.c        2006-01-03 16:16:52.000000000 -0700
307 @@ -626,7 +626,7 @@
308  
309         /* We are done with atomic stuff, now do the rest of housekeeping */
310  
311 -       inode->i_ctime = CURRENT_TIME;
312 +       inode->i_ctime = CURRENT_TIME_SEC;
313         ext3_mark_inode_dirty(handle, inode);
314  
315         /* had we spliced it onto indirect block? */
316 @@ -2199,7 +2199,7 @@
317                         ;
318         }
319         up(&ei->truncate_sem);
320 -       inode->i_mtime = inode->i_ctime = CURRENT_TIME;
321 +       inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
322         ext3_mark_inode_dirty(handle, inode);
323  
324         /* In a multi-transaction truncate, we only make the final
325 Index: linux-2.6.10/fs/ext3/ioctl.c
326 ===================================================================
327 --- linux-2.6.10.orig/fs/ext3/ioctl.c   2004-12-24 14:34:31.000000000 -0700
328 +++ linux-2.6.10/fs/ext3/ioctl.c        2006-01-03 16:16:52.000000000 -0700
329 @@ -87,7 +87,7 @@
330                 ei->i_flags = flags;
331  
332                 ext3_set_inode_flags(inode);
333 -               inode->i_ctime = CURRENT_TIME;
334 +               inode->i_ctime = CURRENT_TIME_SEC;
335  
336                 err = ext3_mark_iloc_dirty(handle, inode, &iloc);
337  flags_err:
338 @@ -121,7 +121,7 @@
339                         return PTR_ERR(handle);
340                 err = ext3_reserve_inode_write(handle, inode, &iloc);
341                 if (err == 0) {
342 -                       inode->i_ctime = CURRENT_TIME;
343 +                       inode->i_ctime = CURRENT_TIME_SEC;
344                         inode->i_generation = generation;
345                         err = ext3_mark_iloc_dirty(handle, inode, &iloc);
346                 }
347 Index: linux-2.6.10/fs/ext3/namei.c
348 ===================================================================
349 --- linux-2.6.10.orig/fs/ext3/namei.c   2004-12-24 14:34:58.000000000 -0700
350 +++ linux-2.6.10/fs/ext3/namei.c        2006-01-03 16:16:52.000000000 -0700
351 @@ -1251,7 +1251,7 @@
352          * happen is that the times are slightly out of date
353          * and/or different from the directory change time.
354          */
355 -       dir->i_mtime = dir->i_ctime = CURRENT_TIME;
356 +       dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
357         ext3_update_dx_flag(dir);
358         dir->i_version++;
359         ext3_mark_inode_dirty(handle, dir);
360 @@ -2029,7 +2029,7 @@
361          * recovery. */
362         inode->i_size = 0;
363         ext3_orphan_add(handle, inode);
364 -       inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
365 +       inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
366         ext3_mark_inode_dirty(handle, inode);
367         dir->i_nlink--;
368         ext3_update_dx_flag(dir);
369 @@ -2079,7 +2079,7 @@
370         retval = ext3_delete_entry(handle, dir, de, bh);
371         if (retval)
372                 goto end_unlink;
373 -       dir->i_ctime = dir->i_mtime = CURRENT_TIME;
374 +       dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
375         ext3_update_dx_flag(dir);
376         ext3_mark_inode_dirty(handle, dir);
377         inode->i_nlink--;
378 @@ -2169,7 +2169,7 @@
379         if (IS_DIRSYNC(dir))
380                 handle->h_sync = 1;
381  
382 -       inode->i_ctime = CURRENT_TIME;
383 +       inode->i_ctime = CURRENT_TIME_SEC;
384         ext3_inc_count(handle, inode);
385         atomic_inc(&inode->i_count);
386  
387 @@ -2270,7 +2270,7 @@
388          * Like most other Unix systems, set the ctime for inodes on a
389          * rename.
390          */
391 -       old_inode->i_ctime = CURRENT_TIME;
392 +       old_inode->i_ctime = CURRENT_TIME_SEC;
393         ext3_mark_inode_dirty(handle, old_inode);
394  
395         /*
396 @@ -2303,9 +2303,9 @@
397  
398         if (new_inode) {
399                 new_inode->i_nlink--;
400 -               new_inode->i_ctime = CURRENT_TIME;
401 +               new_inode->i_ctime = CURRENT_TIME_SEC;
402         }
403 -       old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
404 +       old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC;
405         ext3_update_dx_flag(old_dir);
406         if (dir_bh) {
407                 BUFFER_TRACE(dir_bh, "get_write_access");
408 Index: linux-2.6.10/fs/ext3/super.c
409 ===================================================================
410 --- linux-2.6.10.orig/fs/ext3/super.c   2005-04-06 09:38:35.000000000 -0600
411 +++ linux-2.6.10/fs/ext3/super.c        2006-01-03 16:16:52.000000000 -0700
412 @@ -1318,7 +1318,7 @@
413         if (!parse_options ((char *) data, sb, &journal_inum, NULL, 0))
414                 goto failed_mount;
415  
416 -       sb->s_flags |= MS_ONE_SECOND;
417 +       set_sb_time_gran(sb, 1000000000U);
418         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
419                 ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
420  
421 Index: linux-2.6.10/fs/ext3/xattr.c
422 ===================================================================
423 --- linux-2.6.10.orig/fs/ext3/xattr.c   2005-04-06 09:38:35.000000000 -0600
424 +++ linux-2.6.10/fs/ext3/xattr.c        2006-01-03 16:16:52.000000000 -0700
425 @@ -723,7 +723,7 @@
426  
427         /* Update the inode. */
428         EXT3_I(inode)->i_file_acl = new_bh ? new_bh->b_blocknr : 0;
429 -       inode->i_ctime = CURRENT_TIME;
430 +       inode->i_ctime = CURRENT_TIME_SEC;
431         ext3_mark_inode_dirty(handle, inode);
432         if (IS_SYNC(inode))
433                 handle->h_sync = 1;
434 Index: linux-2.6.10/fs/inode.c
435 ===================================================================
436 --- linux-2.6.10.orig/fs/inode.c        2006-01-03 15:33:21.000000000 -0700
437 +++ linux-2.6.10/fs/inode.c     2006-01-03 16:16:52.000000000 -0700
438 @@ -1131,19 +1131,6 @@
439  
440  EXPORT_SYMBOL(bmap);
441  
442 -/*
443 - * Return true if the filesystem which backs this inode considers the two
444 - * passed timespecs to be sufficiently different to warrant flushing the
445 - * altered time out to disk.
446 - */
447 -static int inode_times_differ(struct inode *inode,
448 -                       struct timespec *old, struct timespec *new)
449 -{
450 -       if (IS_ONE_SECOND(inode))
451 -               return old->tv_sec != new->tv_sec;
452 -       return !timespec_equal(old, new);
453 -}
454 -
455  /**
456   *     update_atime    -       update the access time
457   *     @inode: inode accessed
458 @@ -1163,8 +1150,8 @@
459         if (IS_RDONLY(inode))
460                 return;
461  
462 -       now = current_kernel_time();
463 -       if (inode_times_differ(inode, &inode->i_atime, &now)) {
464 +       now = current_fs_time(inode->i_sb);
465 +       if (!timespec_equal(&inode->i_atime, &now)) {
466                 inode->i_atime = now;
467                 mark_inode_dirty_sync(inode);
468         } else {
469 @@ -1194,14 +1181,13 @@
470         if (IS_RDONLY(inode))
471                 return;
472  
473 -       now = current_kernel_time();
474 -
475 -       if (inode_times_differ(inode, &inode->i_mtime, &now))
476 +       now = current_fs_time(inode->i_sb);
477 +       if (!timespec_equal(&inode->i_mtime, &now))
478                 sync_it = 1;
479         inode->i_mtime = now;
480  
481         if (ctime_too) {
482 -               if (inode_times_differ(inode, &inode->i_ctime, &now))
483 +               if (!timespec_equal(&inode->i_ctime, &now))
484                         sync_it = 1;
485                 inode->i_ctime = now;
486         }
487 Index: linux-2.6.10/fs/locks.c
488 ===================================================================
489 --- linux-2.6.10.orig/fs/locks.c        2004-12-24 14:35:28.000000000 -0700
490 +++ linux-2.6.10/fs/locks.c     2006-01-03 16:16:52.000000000 -0700
491 @@ -1228,7 +1228,7 @@
492  {
493         struct file_lock *flock = inode->i_flock;
494         if (flock && IS_LEASE(flock) && (flock->fl_type & F_WRLCK))
495 -               *time = CURRENT_TIME;
496 +               *time = current_fs_time(inode->i_sb);
497         else
498                 *time = inode->i_mtime;
499  }
500 Index: linux-2.6.10/include/linux/fs.h
501 ===================================================================
502 --- linux-2.6.10.orig/include/linux/fs.h        2006-01-03 16:04:26.000000000 -0700
503 +++ linux-2.6.10/include/linux/fs.h     2006-01-03 16:16:52.000000000 -0700
504 @@ -124,7 +124,8 @@
505  #define MS_REC         16384
506  #define MS_VERBOSE     32768
507  #define MS_POSIXACL    (1<<16) /* VFS does not apply the umask */
508 -#define MS_ONE_SECOND  (1<<17) /* fs has 1 sec a/m/ctime resolution */
509 +#define MS_ONE_SECOND  (1<<17) /* fs has 1 sec time resolution (obsolete) */
510 +#define MS_TIME_GRAN   (1<<18) /* fs has s_time_gran field */
511  #define MS_ACTIVE      (1<<30)
512  #define MS_NOUSER      (1<<31)
513  
514 @@ -803,8 +804,33 @@
515          * even looking at it. You had been warned.
516          */
517         struct semaphore s_vfs_rename_sem;      /* Kludge */
518 +
519 +       /* Granuality of c/m/atime in ns.
520 +          Cannot be worse than a second */
521 +#ifndef __GENKSYMS__
522 +       u32                s_time_gran;
523 +#endif
524  };
525  
526 +extern struct timespec current_fs_time(struct super_block *sb);
527 +
528 +static inline u32 get_sb_time_gran(struct super_block *sb) 
529 +{
530 +       if (sb->s_flags & MS_TIME_GRAN) 
531 +               return sb->s_time_gran;
532 +       if (sb->s_flags & MS_ONE_SECOND)
533 +               return 1000000000U;
534 +       return 1;
535 +}
536 +
537 +static inline void set_sb_time_gran(struct super_block *sb, u32 time_gran)
538 +{
539 +       sb->s_time_gran = time_gran;
540 +       sb->s_flags |= MS_TIME_GRAN;
541 +       if (time_gran == 1000000000U)
542 +               sb->s_flags |= MS_ONE_SECOND;
543 +}
544 +
545  /*
546   * Snapshotting support.
547   */
548 Index: linux-2.6.10/include/linux/time.h
549 ===================================================================
550 --- linux-2.6.10.orig/include/linux/time.h      2004-12-24 14:35:00.000000000 -0700
551 +++ linux-2.6.10/include/linux/time.h   2006-01-03 16:16:52.000000000 -0700
552 @@ -90,6 +90,7 @@
553  struct timespec current_kernel_time(void);
554  
555  #define CURRENT_TIME (current_kernel_time())
556 +#define CURRENT_TIME_SEC ((struct timespec) { xtime.tv_sec, 0 })
557  
558  extern void do_gettimeofday(struct timeval *tv);
559  extern int do_settimeofday(struct timespec *tv);
560 @@ -103,6 +104,8 @@
561  extern int do_getitimer(int which, struct itimerval *value);
562  extern void getnstimeofday (struct timespec *tv);
563  
564 +extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
565 +
566  static inline void
567  set_normalized_timespec (struct timespec *ts, time_t sec, long nsec)
568  {
569 Index: linux-2.6.10/kernel/time.c
570 ===================================================================
571 --- linux-2.6.10.orig/kernel/time.c     2004-12-24 14:34:26.000000000 -0700
572 +++ linux-2.6.10/kernel/time.c  2006-01-03 16:16:52.000000000 -0700
573 @@ -36,6 +36,7 @@
574  
575  #include <asm/uaccess.h>
576  #include <asm/unistd.h>
577 +#include <linux/fs.h>
578  
579  /* 
580   * The timezone where the local system is located.  Used as a default by some
581 @@ -433,6 +434,50 @@
582  
583  EXPORT_SYMBOL(current_kernel_time);
584  
585 +/**
586 + * current_fs_time - Return FS time
587 + * @sb: Superblock.
588 + *
589 + * Return the current time truncated to the time granuality supported by
590 + * the fs.
591 + */
592 +struct timespec current_fs_time(struct super_block *sb)
593 +{
594 +       struct timespec now = current_kernel_time();
595 +       return timespec_trunc(now, get_sb_time_gran(sb));
596 +}
597 +EXPORT_SYMBOL(current_fs_time);
598 +
599 +/**
600 + * timespec_trunc - Truncate timespec to a granuality
601 + * @t: Timespec
602 + * @gran: Granuality in ns.
603 + *
604 + * Truncate a timespec to a granuality. gran must be smaller than a second.
605 + * Always rounds down.
606 + *
607 + * This function should be only used for timestamps returned by
608 + * current_kernel_time() or CURRENT_TIME, not with do_gettimeofday() because
609 + * it doesn't handle the better resolution of the later.
610 + */
611 +struct timespec timespec_trunc(struct timespec t, unsigned gran)
612 +{
613 +       /*
614 +        * Division is pretty slow so avoid it for common cases.
615 +        * Currently current_kernel_time() never returns better than
616 +        * jiffies resolution. Exploit that.
617 +        */
618 +       if (gran <= jiffies_to_usecs(1) * 1000) {
619 +               /* nothing */
620 +       } else if (gran == 1000000000) {
621 +               t.tv_nsec = 0;
622 +       } else {
623 +               t.tv_nsec -= t.tv_nsec % gran;
624 +       }
625 +       return t;
626 +}
627 +EXPORT_SYMBOL(timespec_trunc);
628 +
629  #ifdef CONFIG_TIME_INTERPOLATION
630  void getnstimeofday (struct timespec *tv)
631  {