diff options
-rw-r--r-- | fs/ubifs/Kconfig | 15 | ||||
-rw-r--r-- | fs/ubifs/dir.c | 3 | ||||
-rw-r--r-- | fs/ubifs/file.c | 50 | ||||
-rw-r--r-- | fs/ubifs/super.c | 12 | ||||
-rw-r--r-- | fs/ubifs/ubifs.h | 3 |
5 files changed, 81 insertions, 2 deletions
diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig index ba66d508006a..7ff7712f284e 100644 --- a/fs/ubifs/Kconfig +++ b/fs/ubifs/Kconfig | |||
@@ -35,3 +35,18 @@ config UBIFS_FS_ZLIB | |||
35 | default y | 35 | default y |
36 | help | 36 | help |
37 | Zlib compresses better than LZO but it is slower. Say 'Y' if unsure. | 37 | Zlib compresses better than LZO but it is slower. Say 'Y' if unsure. |
38 | |||
39 | config UBIFS_ATIME_SUPPORT | ||
40 | bool "Access time support" if UBIFS_FS | ||
41 | depends on UBIFS_FS | ||
42 | default n | ||
43 | help | ||
44 | Originally UBIFS did not support atime, because it looked like a bad idea due | ||
45 | increased flash wear. This option adds atime support and it is disabled by default | ||
46 | to preserve the old behavior. If you enable this option, UBIFS starts updating atime, | ||
47 | which means that file-system read operations will cause writes (inode atime | ||
48 | updates). This may affect file-system performance and increase flash device wear, | ||
49 | so be careful. How often atime is updated depends on the selected strategy: | ||
50 | strictatime is the "heavy", relatime is "lighter", etc. | ||
51 | |||
52 | If unsure, say 'N' | ||
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index a2f9d978b110..e49bd2808bf3 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c | |||
@@ -1186,6 +1186,9 @@ const struct inode_operations ubifs_dir_inode_operations = { | |||
1186 | .getxattr = ubifs_getxattr, | 1186 | .getxattr = ubifs_getxattr, |
1187 | .listxattr = ubifs_listxattr, | 1187 | .listxattr = ubifs_listxattr, |
1188 | .removexattr = ubifs_removexattr, | 1188 | .removexattr = ubifs_removexattr, |
1189 | #ifdef CONFIG_UBIFS_ATIME_SUPPORT | ||
1190 | .update_time = ubifs_update_time, | ||
1191 | #endif | ||
1189 | }; | 1192 | }; |
1190 | 1193 | ||
1191 | const struct file_operations ubifs_dir_operations = { | 1194 | const struct file_operations ubifs_dir_operations = { |
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index a3dfe2ae79f2..0edc12856147 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c | |||
@@ -1354,6 +1354,47 @@ static inline int mctime_update_needed(const struct inode *inode, | |||
1354 | return 0; | 1354 | return 0; |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | #ifdef CONFIG_UBIFS_ATIME_SUPPORT | ||
1358 | /** | ||
1359 | * ubifs_update_time - update time of inode. | ||
1360 | * @inode: inode to update | ||
1361 | * | ||
1362 | * This function updates time of the inode. | ||
1363 | */ | ||
1364 | int ubifs_update_time(struct inode *inode, struct timespec *time, | ||
1365 | int flags) | ||
1366 | { | ||
1367 | struct ubifs_inode *ui = ubifs_inode(inode); | ||
1368 | struct ubifs_info *c = inode->i_sb->s_fs_info; | ||
1369 | struct ubifs_budget_req req = { .dirtied_ino = 1, | ||
1370 | .dirtied_ino_d = ALIGN(ui->data_len, 8) }; | ||
1371 | int iflags = I_DIRTY_TIME; | ||
1372 | int err, release; | ||
1373 | |||
1374 | err = ubifs_budget_space(c, &req); | ||
1375 | if (err) | ||
1376 | return err; | ||
1377 | |||
1378 | mutex_lock(&ui->ui_mutex); | ||
1379 | if (flags & S_ATIME) | ||
1380 | inode->i_atime = *time; | ||
1381 | if (flags & S_CTIME) | ||
1382 | inode->i_ctime = *time; | ||
1383 | if (flags & S_MTIME) | ||
1384 | inode->i_mtime = *time; | ||
1385 | |||
1386 | if (!(inode->i_sb->s_flags & MS_LAZYTIME)) | ||
1387 | iflags |= I_DIRTY_SYNC; | ||
1388 | |||
1389 | release = ui->dirty; | ||
1390 | __mark_inode_dirty(inode, iflags); | ||
1391 | mutex_unlock(&ui->ui_mutex); | ||
1392 | if (release) | ||
1393 | ubifs_release_budget(c, &req); | ||
1394 | return 0; | ||
1395 | } | ||
1396 | #endif | ||
1397 | |||
1357 | /** | 1398 | /** |
1358 | * update_ctime - update mtime and ctime of an inode. | 1399 | * update_ctime - update mtime and ctime of an inode. |
1359 | * @inode: inode to update | 1400 | * @inode: inode to update |
@@ -1537,6 +1578,9 @@ static int ubifs_file_mmap(struct file *file, struct vm_area_struct *vma) | |||
1537 | if (err) | 1578 | if (err) |
1538 | return err; | 1579 | return err; |
1539 | vma->vm_ops = &ubifs_file_vm_ops; | 1580 | vma->vm_ops = &ubifs_file_vm_ops; |
1581 | #ifdef CONFIG_UBIFS_ATIME_SUPPORT | ||
1582 | file_accessed(file); | ||
1583 | #endif | ||
1540 | return 0; | 1584 | return 0; |
1541 | } | 1585 | } |
1542 | 1586 | ||
@@ -1557,6 +1601,9 @@ const struct inode_operations ubifs_file_inode_operations = { | |||
1557 | .getxattr = ubifs_getxattr, | 1601 | .getxattr = ubifs_getxattr, |
1558 | .listxattr = ubifs_listxattr, | 1602 | .listxattr = ubifs_listxattr, |
1559 | .removexattr = ubifs_removexattr, | 1603 | .removexattr = ubifs_removexattr, |
1604 | #ifdef CONFIG_UBIFS_ATIME_SUPPORT | ||
1605 | .update_time = ubifs_update_time, | ||
1606 | #endif | ||
1560 | }; | 1607 | }; |
1561 | 1608 | ||
1562 | const struct inode_operations ubifs_symlink_inode_operations = { | 1609 | const struct inode_operations ubifs_symlink_inode_operations = { |
@@ -1568,6 +1615,9 @@ const struct inode_operations ubifs_symlink_inode_operations = { | |||
1568 | .getxattr = ubifs_getxattr, | 1615 | .getxattr = ubifs_getxattr, |
1569 | .listxattr = ubifs_listxattr, | 1616 | .listxattr = ubifs_listxattr, |
1570 | .removexattr = ubifs_removexattr, | 1617 | .removexattr = ubifs_removexattr, |
1618 | #ifdef CONFIG_UBIFS_ATIME_SUPPORT | ||
1619 | .update_time = ubifs_update_time, | ||
1620 | #endif | ||
1571 | }; | 1621 | }; |
1572 | 1622 | ||
1573 | const struct file_operations ubifs_file_operations = { | 1623 | const struct file_operations ubifs_file_operations = { |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 9547a27868ad..8ee3133dd8e4 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -128,7 +128,10 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum) | |||
128 | if (err) | 128 | if (err) |
129 | goto out_ino; | 129 | goto out_ino; |
130 | 130 | ||
131 | inode->i_flags |= (S_NOCMTIME | S_NOATIME); | 131 | inode->i_flags |= S_NOCMTIME; |
132 | #ifndef CONFIG_UBIFS_ATIME_SUPPORT | ||
133 | inode->i_flags |= S_NOATIME; | ||
134 | #endif | ||
132 | set_nlink(inode, le32_to_cpu(ino->nlink)); | 135 | set_nlink(inode, le32_to_cpu(ino->nlink)); |
133 | i_uid_write(inode, le32_to_cpu(ino->uid)); | 136 | i_uid_write(inode, le32_to_cpu(ino->uid)); |
134 | i_gid_write(inode, le32_to_cpu(ino->gid)); | 137 | i_gid_write(inode, le32_to_cpu(ino->gid)); |
@@ -2139,7 +2142,12 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags, | |||
2139 | if (err) | 2142 | if (err) |
2140 | goto out_deact; | 2143 | goto out_deact; |
2141 | /* We do not support atime */ | 2144 | /* We do not support atime */ |
2142 | sb->s_flags |= MS_ACTIVE | MS_NOATIME; | 2145 | sb->s_flags |= MS_ACTIVE; |
2146 | #ifndef CONFIG_UBIFS_ATIME_SUPPORT | ||
2147 | sb->s_flags |= MS_NOATIME; | ||
2148 | #else | ||
2149 | ubifs_msg(c, "full atime support is enabled."); | ||
2150 | #endif | ||
2143 | } | 2151 | } |
2144 | 2152 | ||
2145 | /* 'fill_super()' opens ubi again so we must close it here */ | 2153 | /* 'fill_super()' opens ubi again so we must close it here */ |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 6ef2415aad9d..01142e129d16 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
@@ -1746,6 +1746,9 @@ int ubifs_calc_dark(const struct ubifs_info *c, int spc); | |||
1746 | /* file.c */ | 1746 | /* file.c */ |
1747 | int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync); | 1747 | int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync); |
1748 | int ubifs_setattr(struct dentry *dentry, struct iattr *attr); | 1748 | int ubifs_setattr(struct dentry *dentry, struct iattr *attr); |
1749 | #ifdef CONFIG_UBIFS_ATIME_SUPPORT | ||
1750 | int ubifs_update_time(struct inode *inode, struct timespec *time, int flags); | ||
1751 | #endif | ||
1749 | 1752 | ||
1750 | /* dir.c */ | 1753 | /* dir.c */ |
1751 | struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, | 1754 | struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, |