forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/fs/nilfs2/super.c
....@@ -53,6 +53,7 @@
5353 MODULE_DESCRIPTION("A New Implementation of the Log-structured Filesystem "
5454 "(NILFS)");
5555 MODULE_LICENSE("GPL");
56
+MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
5657
5758 static struct kmem_cache *nilfs_inode_cachep;
5859 struct kmem_cache *nilfs_transaction_cachep;
....@@ -62,19 +63,25 @@
6263 static int nilfs_setup_super(struct super_block *sb, int is_mount);
6364 static int nilfs_remount(struct super_block *sb, int *flags, char *data);
6465
65
-void __nilfs_msg(struct super_block *sb, const char *level, const char *fmt,
66
- ...)
66
+void __nilfs_msg(struct super_block *sb, const char *fmt, ...)
6767 {
6868 struct va_format vaf;
6969 va_list args;
70
+ int level;
7071
7172 va_start(args, fmt);
72
- vaf.fmt = fmt;
73
+
74
+ level = printk_get_level(fmt);
75
+ vaf.fmt = printk_skip_level(fmt);
7376 vaf.va = &args;
77
+
7478 if (sb)
75
- printk("%sNILFS (%s): %pV\n", level, sb->s_id, &vaf);
79
+ printk("%c%cNILFS (%s): %pV\n",
80
+ KERN_SOH_ASCII, level, sb->s_id, &vaf);
7681 else
77
- printk("%sNILFS: %pV\n", level, &vaf);
82
+ printk("%c%cNILFS: %pV\n",
83
+ KERN_SOH_ASCII, level, &vaf);
84
+
7885 va_end(args);
7986 }
8087
....@@ -106,7 +113,7 @@
106113 *
107114 * This implements the body of nilfs_error() macro. Normally,
108115 * nilfs_error() should be used. As for sustainable errors such as a
109
- * single-shot I/O error, nilfs_msg() should be used instead.
116
+ * single-shot I/O error, nilfs_err() should be used instead.
110117 *
111118 * Callers should not add a trailing newline since this will do it.
112119 */
....@@ -151,23 +158,17 @@
151158 ii->i_bh = NULL;
152159 ii->i_state = 0;
153160 ii->i_cno = 0;
154
- nilfs_mapping_init(&ii->i_btnode_cache, &ii->vfs_inode);
161
+ ii->i_assoc_inode = NULL;
162
+ ii->i_bmap = &ii->i_bmap_data;
155163 return &ii->vfs_inode;
156164 }
157165
158
-static void nilfs_i_callback(struct rcu_head *head)
166
+static void nilfs_free_inode(struct inode *inode)
159167 {
160
- struct inode *inode = container_of(head, struct inode, i_rcu);
161
-
162168 if (nilfs_is_metadata_file_inode(inode))
163169 nilfs_mdt_destroy(inode);
164170
165171 kmem_cache_free(nilfs_inode_cachep, NILFS_I(inode));
166
-}
167
-
168
-void nilfs_destroy_inode(struct inode *inode)
169
-{
170
- call_rcu(&inode->i_rcu, nilfs_i_callback);
171172 }
172173
173174 static int nilfs_sync_super(struct super_block *sb, int flag)
....@@ -185,8 +186,7 @@
185186 }
186187
187188 if (unlikely(err)) {
188
- nilfs_msg(sb, KERN_ERR, "unable to write superblock: err=%d",
189
- err);
189
+ nilfs_err(sb, "unable to write superblock: err=%d", err);
190190 if (err == -EIO && nilfs->ns_sbh[1]) {
191191 /*
192192 * sbp[0] points to newer log than sbp[1],
....@@ -256,7 +256,7 @@
256256 sbp[1]->s_magic == cpu_to_le16(NILFS_SUPER_MAGIC)) {
257257 memcpy(sbp[0], sbp[1], nilfs->ns_sbsize);
258258 } else {
259
- nilfs_msg(sb, KERN_CRIT, "superblock broke");
259
+ nilfs_crit(sb, "superblock broke");
260260 return NULL;
261261 }
262262 } else if (sbp[1] &&
....@@ -366,9 +366,9 @@
366366 offset = sb2off & (nilfs->ns_blocksize - 1);
367367 nsbh = sb_getblk(sb, newblocknr);
368368 if (!nsbh) {
369
- nilfs_msg(sb, KERN_WARNING,
370
- "unable to move secondary superblock to block %llu",
371
- (unsigned long long)newblocknr);
369
+ nilfs_warn(sb,
370
+ "unable to move secondary superblock to block %llu",
371
+ (unsigned long long)newblocknr);
372372 ret = -EIO;
373373 goto out;
374374 }
....@@ -531,7 +531,7 @@
531531 up_read(&nilfs->ns_segctor_sem);
532532 if (unlikely(err)) {
533533 if (err == -ENOENT || err == -EINVAL) {
534
- nilfs_msg(sb, KERN_ERR,
534
+ nilfs_err(sb,
535535 "Invalid checkpoint (checkpoint number=%llu)",
536536 (unsigned long long)cno);
537537 err = -EINVAL;
....@@ -629,8 +629,7 @@
629629 err = nilfs_ifile_count_free_inodes(root->ifile,
630630 &nmaxinodes, &nfreeinodes);
631631 if (unlikely(err)) {
632
- nilfs_msg(sb, KERN_WARNING,
633
- "failed to count free inodes: err=%d", err);
632
+ nilfs_warn(sb, "failed to count free inodes: err=%d", err);
634633 if (err == -ERANGE) {
635634 /*
636635 * If nilfs_palloc_count_max_entries() returns
....@@ -654,8 +653,7 @@
654653 buf->f_files = nmaxinodes;
655654 buf->f_ffree = nfreeinodes;
656655 buf->f_namelen = NILFS_NAME_LEN;
657
- buf->f_fsid.val[0] = (u32)id;
658
- buf->f_fsid.val[1] = (u32)(id >> 32);
656
+ buf->f_fsid = u64_to_fsid(id);
659657
660658 return 0;
661659 }
....@@ -686,7 +684,7 @@
686684
687685 static const struct super_operations nilfs_sops = {
688686 .alloc_inode = nilfs_alloc_inode,
689
- .destroy_inode = nilfs_destroy_inode,
687
+ .free_inode = nilfs_free_inode,
690688 .dirty_inode = nilfs_dirty_inode,
691689 .evict_inode = nilfs_evict_inode,
692690 .put_super = nilfs_put_super,
....@@ -762,7 +760,7 @@
762760 break;
763761 case Opt_snapshot:
764762 if (is_remount) {
765
- nilfs_msg(sb, KERN_ERR,
763
+ nilfs_err(sb,
766764 "\"%s\" option is invalid for remount",
767765 p);
768766 return 0;
....@@ -778,8 +776,7 @@
778776 nilfs_clear_opt(nilfs, DISCARD);
779777 break;
780778 default:
781
- nilfs_msg(sb, KERN_ERR,
782
- "unrecognized mount option \"%s\"", p);
779
+ nilfs_err(sb, "unrecognized mount option \"%s\"", p);
783780 return 0;
784781 }
785782 }
....@@ -815,10 +812,10 @@
815812 mnt_count = le16_to_cpu(sbp[0]->s_mnt_count);
816813
817814 if (nilfs->ns_mount_state & NILFS_ERROR_FS) {
818
- nilfs_msg(sb, KERN_WARNING, "mounting fs with errors");
815
+ nilfs_warn(sb, "mounting fs with errors");
819816 #if 0
820817 } else if (max_mnt_count >= 0 && mnt_count >= max_mnt_count) {
821
- nilfs_msg(sb, KERN_WARNING, "maximal mount count reached");
818
+ nilfs_warn(sb, "maximal mount count reached");
822819 #endif
823820 }
824821 if (!max_mnt_count)
....@@ -881,7 +878,7 @@
881878 features = le64_to_cpu(sbp->s_feature_incompat) &
882879 ~NILFS_FEATURE_INCOMPAT_SUPP;
883880 if (features) {
884
- nilfs_msg(sb, KERN_ERR,
881
+ nilfs_err(sb,
885882 "couldn't mount because of unsupported optional features (%llx)",
886883 (unsigned long long)features);
887884 return -EINVAL;
....@@ -889,7 +886,7 @@
889886 features = le64_to_cpu(sbp->s_feature_compat_ro) &
890887 ~NILFS_FEATURE_COMPAT_RO_SUPP;
891888 if (!sb_rdonly(sb) && features) {
892
- nilfs_msg(sb, KERN_ERR,
889
+ nilfs_err(sb,
893890 "couldn't mount RDWR because of unsupported optional features (%llx)",
894891 (unsigned long long)features);
895892 return -EINVAL;
....@@ -908,12 +905,12 @@
908905 inode = nilfs_iget(sb, root, NILFS_ROOT_INO);
909906 if (IS_ERR(inode)) {
910907 ret = PTR_ERR(inode);
911
- nilfs_msg(sb, KERN_ERR, "error %d getting root inode", ret);
908
+ nilfs_err(sb, "error %d getting root inode", ret);
912909 goto out;
913910 }
914911 if (!S_ISDIR(inode->i_mode) || !inode->i_blocks || !inode->i_size) {
915912 iput(inode);
916
- nilfs_msg(sb, KERN_ERR, "corrupt root inode");
913
+ nilfs_err(sb, "corrupt root inode");
917914 ret = -EINVAL;
918915 goto out;
919916 }
....@@ -941,7 +938,7 @@
941938 return ret;
942939
943940 failed_dentry:
944
- nilfs_msg(sb, KERN_ERR, "error %d getting root dentry", ret);
941
+ nilfs_err(sb, "error %d getting root dentry", ret);
945942 goto out;
946943 }
947944
....@@ -961,7 +958,7 @@
961958 ret = (ret == -ENOENT) ? -EINVAL : ret;
962959 goto out;
963960 } else if (!ret) {
964
- nilfs_msg(s, KERN_ERR,
961
+ nilfs_err(s,
965962 "The specified checkpoint is not a snapshot (checkpoint number=%llu)",
966963 (unsigned long long)cno);
967964 ret = -EINVAL;
....@@ -970,7 +967,7 @@
970967
971968 ret = nilfs_attach_checkpoint(s, cno, false, &root);
972969 if (ret) {
973
- nilfs_msg(s, KERN_ERR,
970
+ nilfs_err(s,
974971 "error %d while loading snapshot (checkpoint number=%llu)",
975972 ret, (unsigned long long)cno);
976973 goto out;
....@@ -1067,7 +1064,7 @@
10671064 cno = nilfs_last_cno(nilfs);
10681065 err = nilfs_attach_checkpoint(sb, cno, true, &fsroot);
10691066 if (err) {
1070
- nilfs_msg(sb, KERN_ERR,
1067
+ nilfs_err(sb,
10711068 "error %d while loading last checkpoint (checkpoint number=%llu)",
10721069 err, (unsigned long long)cno);
10731070 goto failed_unload;
....@@ -1129,16 +1126,14 @@
11291126 err = -EINVAL;
11301127
11311128 if (!nilfs_valid_fs(nilfs)) {
1132
- nilfs_msg(sb, KERN_WARNING,
1133
- "couldn't remount because the filesystem is in an incomplete recovery state");
1129
+ nilfs_warn(sb,
1130
+ "couldn't remount because the filesystem is in an incomplete recovery state");
11341131 goto restore_opts;
11351132 }
11361133
11371134 if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb))
11381135 goto out;
11391136 if (*flags & SB_RDONLY) {
1140
- /* Shutting down log writer */
1141
- nilfs_detach_log_writer(sb);
11421137 sb->s_flags |= SB_RDONLY;
11431138
11441139 /*
....@@ -1162,9 +1157,9 @@
11621157 ~NILFS_FEATURE_COMPAT_RO_SUPP;
11631158 up_read(&nilfs->ns_sem);
11641159 if (features) {
1165
- nilfs_msg(sb, KERN_WARNING,
1166
- "couldn't remount RDWR because of unsupported optional features (%llx)",
1167
- (unsigned long long)features);
1160
+ nilfs_warn(sb,
1161
+ "couldn't remount RDWR because of unsupported optional features (%llx)",
1162
+ (unsigned long long)features);
11681163 err = -EROFS;
11691164 goto restore_opts;
11701165 }
....@@ -1223,7 +1218,7 @@
12231218 return 0;
12241219
12251220 parse_error:
1226
- nilfs_msg(NULL, KERN_ERR, "invalid option \"%s\": %s", option, msg);
1221
+ nilfs_err(NULL, "invalid option \"%s\": %s", option, msg);
12271222 return 1;
12281223 }
12291224
....@@ -1326,7 +1321,7 @@
13261321 } else if (!sd.cno) {
13271322 if (nilfs_tree_is_busy(s->s_root)) {
13281323 if ((flags ^ s->s_flags) & SB_RDONLY) {
1329
- nilfs_msg(s, KERN_ERR,
1324
+ nilfs_err(s,
13301325 "the device already has a %s mount.",
13311326 sb_rdonly(s) ? "read-only" : "read/write");
13321327 err = -EBUSY;
....@@ -1382,8 +1377,6 @@
13821377 #ifdef CONFIG_NILFS_XATTR
13831378 init_rwsem(&ii->xattr_sem);
13841379 #endif
1385
- address_space_init_once(&ii->i_btnode_cache);
1386
- ii->i_bmap = &ii->i_bmap_data;
13871380 inode_init_once(&ii->vfs_inode);
13881381 }
13891382