forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/fs/ubifs/file.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * This file is part of UBIFS.
34 *
45 * Copyright (C) 2006-2008 Nokia Corporation.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published by
8
- * the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
15
- * You should have received a copy of the GNU General Public License along with
16
- * this program; if not, write to the Free Software Foundation, Inc., 51
17
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
186 *
197 * Authors: Artem Bityutskiy (Битюцкий Артём)
208 * Adrian Hunter
....@@ -79,7 +67,7 @@
7967
8068 dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
8169
82
- if (ubifs_crypt_is_encrypted(inode)) {
70
+ if (IS_ENCRYPTED(inode)) {
8371 err = ubifs_decrypt(inode, dn, &dlen, block);
8472 if (err)
8573 goto dump;
....@@ -234,7 +222,7 @@
234222 struct ubifs_info *c = inode->i_sb->s_fs_info;
235223 pgoff_t index = pos >> PAGE_SHIFT;
236224 struct ubifs_budget_req req = { .new_page = 1 };
237
- int uninitialized_var(err), appending = !!(pos + len > inode->i_size);
225
+ int err, appending = !!(pos + len > inode->i_size);
238226 struct page *page;
239227
240228 dbg_gen("ino %lu, pos %llu, len %u, i_size %lld",
....@@ -438,7 +426,7 @@
438426 struct ubifs_info *c = inode->i_sb->s_fs_info;
439427 struct ubifs_inode *ui = ubifs_inode(inode);
440428 pgoff_t index = pos >> PAGE_SHIFT;
441
- int uninitialized_var(err), appending = !!(pos + len > inode->i_size);
429
+ int err, appending = !!(pos + len > inode->i_size);
442430 int skipped_read = 0;
443431 struct page *page;
444432
....@@ -582,7 +570,7 @@
582570 }
583571
584572 if (!PagePrivate(page)) {
585
- SetPagePrivate(page);
573
+ attach_page_private(page, (void *)1);
586574 atomic_long_inc(&c->dirty_pg_cnt);
587575 __set_page_dirty_nobuffers(page);
588576 }
....@@ -659,7 +647,7 @@
659647 dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
660648 out_len = UBIFS_BLOCK_SIZE;
661649
662
- if (ubifs_crypt_is_encrypted(inode)) {
650
+ if (IS_ENCRYPTED(inode)) {
663651 err = ubifs_decrypt(inode, dn, &dlen, page_block);
664652 if (err)
665653 goto out_err;
....@@ -959,7 +947,7 @@
959947 release_existing_page_budget(c);
960948
961949 atomic_long_dec(&c->dirty_pg_cnt);
962
- ClearPagePrivate(page);
950
+ detach_page_private(page);
963951 ClearPageChecked(page);
964952
965953 kunmap(page);
....@@ -1093,14 +1081,11 @@
10931081 if (attr->ia_valid & ATTR_GID)
10941082 inode->i_gid = attr->ia_gid;
10951083 if (attr->ia_valid & ATTR_ATIME)
1096
- inode->i_atime = timespec64_trunc(attr->ia_atime,
1097
- inode->i_sb->s_time_gran);
1084
+ inode->i_atime = attr->ia_atime;
10981085 if (attr->ia_valid & ATTR_MTIME)
1099
- inode->i_mtime = timespec64_trunc(attr->ia_mtime,
1100
- inode->i_sb->s_time_gran);
1086
+ inode->i_mtime = attr->ia_mtime;
11011087 if (attr->ia_valid & ATTR_CTIME)
1102
- inode->i_ctime = timespec64_trunc(attr->ia_ctime,
1103
- inode->i_sb->s_time_gran);
1088
+ inode->i_ctime = attr->ia_ctime;
11041089 if (attr->ia_valid & ATTR_MODE) {
11051090 umode_t mode = attr->ia_mode;
11061091
....@@ -1318,7 +1303,7 @@
13181303 release_existing_page_budget(c);
13191304
13201305 atomic_long_dec(&c->dirty_pg_cnt);
1321
- ClearPagePrivate(page);
1306
+ detach_page_private(page);
13221307 ClearPageChecked(page);
13231308 }
13241309
....@@ -1377,7 +1362,6 @@
13771362 return 0;
13781363 }
13791364
1380
-#ifdef CONFIG_UBIFS_ATIME_SUPPORT
13811365 /**
13821366 * ubifs_update_time - update time of inode.
13831367 * @inode: inode to update
....@@ -1392,6 +1376,9 @@
13921376 struct ubifs_budget_req req = { .dirtied_ino = 1,
13931377 .dirtied_ino_d = ALIGN(ui->data_len, 8) };
13941378 int err, release;
1379
+
1380
+ if (!IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT))
1381
+ return generic_update_time(inode, time, flags);
13951382
13961383 err = ubifs_budget_space(c, &req);
13971384 if (err)
....@@ -1412,7 +1399,6 @@
14121399 ubifs_release_budget(c, &req);
14131400 return 0;
14141401 }
1415
-#endif
14161402
14171403 /**
14181404 * update_mctime - update mtime and ctime of an inode.
....@@ -1479,13 +1465,13 @@
14791465 {
14801466 int rc;
14811467
1482
- rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0);
1468
+ rc = migrate_page_move_mapping(mapping, newpage, page, 0);
14831469 if (rc != MIGRATEPAGE_SUCCESS)
14841470 return rc;
14851471
14861472 if (PagePrivate(page)) {
1487
- ClearPagePrivate(page);
1488
- SetPagePrivate(newpage);
1473
+ detach_page_private(page);
1474
+ attach_page_private(newpage, (void *)1);
14891475 }
14901476
14911477 if (mode != MIGRATE_SYNC_NO_COPY)
....@@ -1509,7 +1495,7 @@
15091495 return 0;
15101496 ubifs_assert(c, PagePrivate(page));
15111497 ubifs_assert(c, 0);
1512
- ClearPagePrivate(page);
1498
+ detach_page_private(page);
15131499 ClearPageChecked(page);
15141500 return 1;
15151501 }
....@@ -1580,7 +1566,7 @@
15801566 else {
15811567 if (!PageChecked(page))
15821568 ubifs_convert_page_budget(c);
1583
- SetPagePrivate(page);
1569
+ attach_page_private(page, (void *)1);
15841570 atomic_long_inc(&c->dirty_pg_cnt);
15851571 __set_page_dirty_nobuffers(page);
15861572 }
....@@ -1621,9 +1607,10 @@
16211607 if (err)
16221608 return err;
16231609 vma->vm_ops = &ubifs_file_vm_ops;
1624
-#ifdef CONFIG_UBIFS_ATIME_SUPPORT
1625
- file_accessed(file);
1626
-#endif
1610
+
1611
+ if (IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT))
1612
+ file_accessed(file);
1613
+
16271614 return 0;
16281615 }
16291616
....@@ -1671,9 +1658,7 @@
16711658 #ifdef CONFIG_UBIFS_FS_XATTR
16721659 .listxattr = ubifs_listxattr,
16731660 #endif
1674
-#ifdef CONFIG_UBIFS_ATIME_SUPPORT
16751661 .update_time = ubifs_update_time,
1676
-#endif
16771662 };
16781663
16791664 const struct inode_operations ubifs_symlink_inode_operations = {
....@@ -1683,9 +1668,7 @@
16831668 #ifdef CONFIG_UBIFS_FS_XATTR
16841669 .listxattr = ubifs_listxattr,
16851670 #endif
1686
-#ifdef CONFIG_UBIFS_ATIME_SUPPORT
16871671 .update_time = ubifs_update_time,
1688
-#endif
16891672 };
16901673
16911674 const struct file_operations ubifs_file_operations = {