| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * This file is part of UBIFS. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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 |
|---|
| 18 | 6 | * |
|---|
| 19 | 7 | * Authors: Artem Bityutskiy (Битюцкий Артём) |
|---|
| 20 | 8 | * Adrian Hunter |
|---|
| .. | .. |
|---|
| 79 | 67 | |
|---|
| 80 | 68 | dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; |
|---|
| 81 | 69 | |
|---|
| 82 | | - if (ubifs_crypt_is_encrypted(inode)) { |
|---|
| 70 | + if (IS_ENCRYPTED(inode)) { |
|---|
| 83 | 71 | err = ubifs_decrypt(inode, dn, &dlen, block); |
|---|
| 84 | 72 | if (err) |
|---|
| 85 | 73 | goto dump; |
|---|
| .. | .. |
|---|
| 234 | 222 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
|---|
| 235 | 223 | pgoff_t index = pos >> PAGE_SHIFT; |
|---|
| 236 | 224 | 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); |
|---|
| 238 | 226 | struct page *page; |
|---|
| 239 | 227 | |
|---|
| 240 | 228 | dbg_gen("ino %lu, pos %llu, len %u, i_size %lld", |
|---|
| .. | .. |
|---|
| 438 | 426 | struct ubifs_info *c = inode->i_sb->s_fs_info; |
|---|
| 439 | 427 | struct ubifs_inode *ui = ubifs_inode(inode); |
|---|
| 440 | 428 | 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); |
|---|
| 442 | 430 | int skipped_read = 0; |
|---|
| 443 | 431 | struct page *page; |
|---|
| 444 | 432 | |
|---|
| .. | .. |
|---|
| 582 | 570 | } |
|---|
| 583 | 571 | |
|---|
| 584 | 572 | if (!PagePrivate(page)) { |
|---|
| 585 | | - SetPagePrivate(page); |
|---|
| 573 | + attach_page_private(page, (void *)1); |
|---|
| 586 | 574 | atomic_long_inc(&c->dirty_pg_cnt); |
|---|
| 587 | 575 | __set_page_dirty_nobuffers(page); |
|---|
| 588 | 576 | } |
|---|
| .. | .. |
|---|
| 659 | 647 | dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ; |
|---|
| 660 | 648 | out_len = UBIFS_BLOCK_SIZE; |
|---|
| 661 | 649 | |
|---|
| 662 | | - if (ubifs_crypt_is_encrypted(inode)) { |
|---|
| 650 | + if (IS_ENCRYPTED(inode)) { |
|---|
| 663 | 651 | err = ubifs_decrypt(inode, dn, &dlen, page_block); |
|---|
| 664 | 652 | if (err) |
|---|
| 665 | 653 | goto out_err; |
|---|
| .. | .. |
|---|
| 959 | 947 | release_existing_page_budget(c); |
|---|
| 960 | 948 | |
|---|
| 961 | 949 | atomic_long_dec(&c->dirty_pg_cnt); |
|---|
| 962 | | - ClearPagePrivate(page); |
|---|
| 950 | + detach_page_private(page); |
|---|
| 963 | 951 | ClearPageChecked(page); |
|---|
| 964 | 952 | |
|---|
| 965 | 953 | kunmap(page); |
|---|
| .. | .. |
|---|
| 1093 | 1081 | if (attr->ia_valid & ATTR_GID) |
|---|
| 1094 | 1082 | inode->i_gid = attr->ia_gid; |
|---|
| 1095 | 1083 | 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; |
|---|
| 1098 | 1085 | 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; |
|---|
| 1101 | 1087 | 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; |
|---|
| 1104 | 1089 | if (attr->ia_valid & ATTR_MODE) { |
|---|
| 1105 | 1090 | umode_t mode = attr->ia_mode; |
|---|
| 1106 | 1091 | |
|---|
| .. | .. |
|---|
| 1318 | 1303 | release_existing_page_budget(c); |
|---|
| 1319 | 1304 | |
|---|
| 1320 | 1305 | atomic_long_dec(&c->dirty_pg_cnt); |
|---|
| 1321 | | - ClearPagePrivate(page); |
|---|
| 1306 | + detach_page_private(page); |
|---|
| 1322 | 1307 | ClearPageChecked(page); |
|---|
| 1323 | 1308 | } |
|---|
| 1324 | 1309 | |
|---|
| .. | .. |
|---|
| 1377 | 1362 | return 0; |
|---|
| 1378 | 1363 | } |
|---|
| 1379 | 1364 | |
|---|
| 1380 | | -#ifdef CONFIG_UBIFS_ATIME_SUPPORT |
|---|
| 1381 | 1365 | /** |
|---|
| 1382 | 1366 | * ubifs_update_time - update time of inode. |
|---|
| 1383 | 1367 | * @inode: inode to update |
|---|
| .. | .. |
|---|
| 1392 | 1376 | struct ubifs_budget_req req = { .dirtied_ino = 1, |
|---|
| 1393 | 1377 | .dirtied_ino_d = ALIGN(ui->data_len, 8) }; |
|---|
| 1394 | 1378 | int err, release; |
|---|
| 1379 | + |
|---|
| 1380 | + if (!IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT)) |
|---|
| 1381 | + return generic_update_time(inode, time, flags); |
|---|
| 1395 | 1382 | |
|---|
| 1396 | 1383 | err = ubifs_budget_space(c, &req); |
|---|
| 1397 | 1384 | if (err) |
|---|
| .. | .. |
|---|
| 1412 | 1399 | ubifs_release_budget(c, &req); |
|---|
| 1413 | 1400 | return 0; |
|---|
| 1414 | 1401 | } |
|---|
| 1415 | | -#endif |
|---|
| 1416 | 1402 | |
|---|
| 1417 | 1403 | /** |
|---|
| 1418 | 1404 | * update_mctime - update mtime and ctime of an inode. |
|---|
| .. | .. |
|---|
| 1479 | 1465 | { |
|---|
| 1480 | 1466 | int rc; |
|---|
| 1481 | 1467 | |
|---|
| 1482 | | - rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0); |
|---|
| 1468 | + rc = migrate_page_move_mapping(mapping, newpage, page, 0); |
|---|
| 1483 | 1469 | if (rc != MIGRATEPAGE_SUCCESS) |
|---|
| 1484 | 1470 | return rc; |
|---|
| 1485 | 1471 | |
|---|
| 1486 | 1472 | if (PagePrivate(page)) { |
|---|
| 1487 | | - ClearPagePrivate(page); |
|---|
| 1488 | | - SetPagePrivate(newpage); |
|---|
| 1473 | + detach_page_private(page); |
|---|
| 1474 | + attach_page_private(newpage, (void *)1); |
|---|
| 1489 | 1475 | } |
|---|
| 1490 | 1476 | |
|---|
| 1491 | 1477 | if (mode != MIGRATE_SYNC_NO_COPY) |
|---|
| .. | .. |
|---|
| 1509 | 1495 | return 0; |
|---|
| 1510 | 1496 | ubifs_assert(c, PagePrivate(page)); |
|---|
| 1511 | 1497 | ubifs_assert(c, 0); |
|---|
| 1512 | | - ClearPagePrivate(page); |
|---|
| 1498 | + detach_page_private(page); |
|---|
| 1513 | 1499 | ClearPageChecked(page); |
|---|
| 1514 | 1500 | return 1; |
|---|
| 1515 | 1501 | } |
|---|
| .. | .. |
|---|
| 1580 | 1566 | else { |
|---|
| 1581 | 1567 | if (!PageChecked(page)) |
|---|
| 1582 | 1568 | ubifs_convert_page_budget(c); |
|---|
| 1583 | | - SetPagePrivate(page); |
|---|
| 1569 | + attach_page_private(page, (void *)1); |
|---|
| 1584 | 1570 | atomic_long_inc(&c->dirty_pg_cnt); |
|---|
| 1585 | 1571 | __set_page_dirty_nobuffers(page); |
|---|
| 1586 | 1572 | } |
|---|
| .. | .. |
|---|
| 1621 | 1607 | if (err) |
|---|
| 1622 | 1608 | return err; |
|---|
| 1623 | 1609 | 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 | + |
|---|
| 1627 | 1614 | return 0; |
|---|
| 1628 | 1615 | } |
|---|
| 1629 | 1616 | |
|---|
| .. | .. |
|---|
| 1671 | 1658 | #ifdef CONFIG_UBIFS_FS_XATTR |
|---|
| 1672 | 1659 | .listxattr = ubifs_listxattr, |
|---|
| 1673 | 1660 | #endif |
|---|
| 1674 | | -#ifdef CONFIG_UBIFS_ATIME_SUPPORT |
|---|
| 1675 | 1661 | .update_time = ubifs_update_time, |
|---|
| 1676 | | -#endif |
|---|
| 1677 | 1662 | }; |
|---|
| 1678 | 1663 | |
|---|
| 1679 | 1664 | const struct inode_operations ubifs_symlink_inode_operations = { |
|---|
| .. | .. |
|---|
| 1683 | 1668 | #ifdef CONFIG_UBIFS_FS_XATTR |
|---|
| 1684 | 1669 | .listxattr = ubifs_listxattr, |
|---|
| 1685 | 1670 | #endif |
|---|
| 1686 | | -#ifdef CONFIG_UBIFS_ATIME_SUPPORT |
|---|
| 1687 | 1671 | .update_time = ubifs_update_time, |
|---|
| 1688 | | -#endif |
|---|
| 1689 | 1672 | }; |
|---|
| 1690 | 1673 | |
|---|
| 1691 | 1674 | const struct file_operations ubifs_file_operations = { |
|---|