journal.c (7afb6d8fa81fd8d332f70ead5e35d8c90abb8165) journal.c (5cf036d4f1489d7ba04b948e415f662521902c30)
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * linux/fs/jbd2/journal.c
4 *
5 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
6 *
7 * Copyright 1998 Red Hat corp --- All Rights Reserved
8 *

--- 1477 unchanged lines hidden (view full) ---

1486 * jbd2_journal_init_inode creates a journal which maps an on-disk inode as
1487 * the journal. The inode must exist already, must support bmap() and
1488 * must have all data blocks preallocated.
1489 */
1490journal_t *jbd2_journal_init_inode(struct inode *inode)
1491{
1492 journal_t *journal;
1493 sector_t blocknr;
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * linux/fs/jbd2/journal.c
4 *
5 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
6 *
7 * Copyright 1998 Red Hat corp --- All Rights Reserved
8 *

--- 1477 unchanged lines hidden (view full) ---

1486 * jbd2_journal_init_inode creates a journal which maps an on-disk inode as
1487 * the journal. The inode must exist already, must support bmap() and
1488 * must have all data blocks preallocated.
1489 */
1490journal_t *jbd2_journal_init_inode(struct inode *inode)
1491{
1492 journal_t *journal;
1493 sector_t blocknr;
1494 char *p;
1494 int err = 0;
1495
1496 blocknr = 0;
1497 err = bmap(inode, &blocknr);
1498
1499 if (err || !blocknr) {
1500 pr_err("%s: Cannot locate journal superblock\n",
1501 __func__);

--- 7 unchanged lines hidden (view full) ---

1509 journal = journal_init_common(inode->i_sb->s_bdev, inode->i_sb->s_bdev,
1510 blocknr, inode->i_size >> inode->i_sb->s_blocksize_bits,
1511 inode->i_sb->s_blocksize);
1512 if (!journal)
1513 return NULL;
1514
1515 journal->j_inode = inode;
1516 snprintf(journal->j_devname, sizeof(journal->j_devname),
1495 int err = 0;
1496
1497 blocknr = 0;
1498 err = bmap(inode, &blocknr);
1499
1500 if (err || !blocknr) {
1501 pr_err("%s: Cannot locate journal superblock\n",
1502 __func__);

--- 7 unchanged lines hidden (view full) ---

1510 journal = journal_init_common(inode->i_sb->s_bdev, inode->i_sb->s_bdev,
1511 blocknr, inode->i_size >> inode->i_sb->s_blocksize_bits,
1512 inode->i_sb->s_blocksize);
1513 if (!journal)
1514 return NULL;
1515
1516 journal->j_inode = inode;
1517 snprintf(journal->j_devname, sizeof(journal->j_devname),
1517 "%pg-%lu", journal->j_dev, journal->j_inode->i_ino);
1518 strreplace(journal->j_devname, '/', '!');
1518 "%pg", journal->j_dev);
1519 p = strreplace(journal->j_devname, '/', '!');
1520 sprintf(p, "-%lu", journal->j_inode->i_ino);
1519 jbd2_stats_proc_init(journal);
1520
1521 return journal;
1522}
1523
1524/*
1525 * If the journal init or create aborts, we need to mark the journal
1526 * superblock as being NULL to prevent the journal destroy from writing

--- 528 unchanged lines hidden (view full) ---

2055 int err;
2056 journal_superblock_t *sb;
2057
2058 err = load_superblock(journal);
2059 if (err)
2060 return err;
2061
2062 sb = journal->j_superblock;
1521 jbd2_stats_proc_init(journal);
1522
1523 return journal;
1524}
1525
1526/*
1527 * If the journal init or create aborts, we need to mark the journal
1528 * superblock as being NULL to prevent the journal destroy from writing

--- 528 unchanged lines hidden (view full) ---

2057 int err;
2058 journal_superblock_t *sb;
2059
2060 err = load_superblock(journal);
2061 if (err)
2062 return err;
2063
2064 sb = journal->j_superblock;
2063 /* If this is a V2 superblock, then we have to check the
2064 * features flags on it. */
2065
2065
2066 if (journal->j_format_version >= 2) {
2066 /*
2067 * If this is a V2 superblock, then we have to check the
2068 * features flags on it.
2069 */
2070 if (jbd2_format_support_feature(journal)) {
2067 if ((sb->s_feature_ro_compat &
2068 ~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) ||
2069 (sb->s_feature_incompat &
2070 ~cpu_to_be32(JBD2_KNOWN_INCOMPAT_FEATURES))) {
2071 printk(KERN_WARNING
2072 "JBD2: Unrecognised features on journal\n");
2073 return -EINVAL;
2074 }

--- 145 unchanged lines hidden (view full) ---

2220 journal_superblock_t *sb;
2221
2222 if (!compat && !ro && !incompat)
2223 return 1;
2224 /* Load journal superblock if it is not loaded yet. */
2225 if (journal->j_format_version == 0 &&
2226 journal_get_superblock(journal) != 0)
2227 return 0;
2071 if ((sb->s_feature_ro_compat &
2072 ~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) ||
2073 (sb->s_feature_incompat &
2074 ~cpu_to_be32(JBD2_KNOWN_INCOMPAT_FEATURES))) {
2075 printk(KERN_WARNING
2076 "JBD2: Unrecognised features on journal\n");
2077 return -EINVAL;
2078 }

--- 145 unchanged lines hidden (view full) ---

2224 journal_superblock_t *sb;
2225
2226 if (!compat && !ro && !incompat)
2227 return 1;
2228 /* Load journal superblock if it is not loaded yet. */
2229 if (journal->j_format_version == 0 &&
2230 journal_get_superblock(journal) != 0)
2231 return 0;
2228 if (journal->j_format_version == 1)
2232 if (!jbd2_format_support_feature(journal))
2229 return 0;
2230
2231 sb = journal->j_superblock;
2232
2233 if (((be32_to_cpu(sb->s_feature_compat) & compat) == compat) &&
2234 ((be32_to_cpu(sb->s_feature_ro_compat) & ro) == ro) &&
2235 ((be32_to_cpu(sb->s_feature_incompat) & incompat) == incompat))
2236 return 1;

--- 13 unchanged lines hidden (view full) ---

2250 * (non-zero) if it can. */
2251
2252int jbd2_journal_check_available_features(journal_t *journal, unsigned long compat,
2253 unsigned long ro, unsigned long incompat)
2254{
2255 if (!compat && !ro && !incompat)
2256 return 1;
2257
2233 return 0;
2234
2235 sb = journal->j_superblock;
2236
2237 if (((be32_to_cpu(sb->s_feature_compat) & compat) == compat) &&
2238 ((be32_to_cpu(sb->s_feature_ro_compat) & ro) == ro) &&
2239 ((be32_to_cpu(sb->s_feature_incompat) & incompat) == incompat))
2240 return 1;

--- 13 unchanged lines hidden (view full) ---

2254 * (non-zero) if it can. */
2255
2256int jbd2_journal_check_available_features(journal_t *journal, unsigned long compat,
2257 unsigned long ro, unsigned long incompat)
2258{
2259 if (!compat && !ro && !incompat)
2260 return 1;
2261
2258 /* We can support any known requested features iff the
2259 * superblock is in version 2. Otherwise we fail to support any
2260 * extended sb features. */
2261
2262 if (journal->j_format_version != 2)
2262 if (!jbd2_format_support_feature(journal))
2263 return 0;
2264
2265 if ((compat & JBD2_KNOWN_COMPAT_FEATURES) == compat &&
2266 (ro & JBD2_KNOWN_ROCOMPAT_FEATURES) == ro &&
2267 (incompat & JBD2_KNOWN_INCOMPAT_FEATURES) == incompat)
2268 return 1;
2269
2270 return 0;

--- 930 unchanged lines hidden ---
2263 return 0;
2264
2265 if ((compat & JBD2_KNOWN_COMPAT_FEATURES) == compat &&
2266 (ro & JBD2_KNOWN_ROCOMPAT_FEATURES) == ro &&
2267 (incompat & JBD2_KNOWN_INCOMPAT_FEATURES) == incompat)
2268 return 1;
2269
2270 return 0;

--- 930 unchanged lines hidden ---