| .. | .. |
|---|
| 53 | 53 | MODULE_DESCRIPTION("A New Implementation of the Log-structured Filesystem " |
|---|
| 54 | 54 | "(NILFS)"); |
|---|
| 55 | 55 | MODULE_LICENSE("GPL"); |
|---|
| 56 | +MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY); |
|---|
| 56 | 57 | |
|---|
| 57 | 58 | static struct kmem_cache *nilfs_inode_cachep; |
|---|
| 58 | 59 | struct kmem_cache *nilfs_transaction_cachep; |
|---|
| .. | .. |
|---|
| 62 | 63 | static int nilfs_setup_super(struct super_block *sb, int is_mount); |
|---|
| 63 | 64 | static int nilfs_remount(struct super_block *sb, int *flags, char *data); |
|---|
| 64 | 65 | |
|---|
| 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, ...) |
|---|
| 67 | 67 | { |
|---|
| 68 | 68 | struct va_format vaf; |
|---|
| 69 | 69 | va_list args; |
|---|
| 70 | + int level; |
|---|
| 70 | 71 | |
|---|
| 71 | 72 | va_start(args, fmt); |
|---|
| 72 | | - vaf.fmt = fmt; |
|---|
| 73 | + |
|---|
| 74 | + level = printk_get_level(fmt); |
|---|
| 75 | + vaf.fmt = printk_skip_level(fmt); |
|---|
| 73 | 76 | vaf.va = &args; |
|---|
| 77 | + |
|---|
| 74 | 78 | 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); |
|---|
| 76 | 81 | else |
|---|
| 77 | | - printk("%sNILFS: %pV\n", level, &vaf); |
|---|
| 82 | + printk("%c%cNILFS: %pV\n", |
|---|
| 83 | + KERN_SOH_ASCII, level, &vaf); |
|---|
| 84 | + |
|---|
| 78 | 85 | va_end(args); |
|---|
| 79 | 86 | } |
|---|
| 80 | 87 | |
|---|
| .. | .. |
|---|
| 106 | 113 | * |
|---|
| 107 | 114 | * This implements the body of nilfs_error() macro. Normally, |
|---|
| 108 | 115 | * 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. |
|---|
| 110 | 117 | * |
|---|
| 111 | 118 | * Callers should not add a trailing newline since this will do it. |
|---|
| 112 | 119 | */ |
|---|
| .. | .. |
|---|
| 151 | 158 | ii->i_bh = NULL; |
|---|
| 152 | 159 | ii->i_state = 0; |
|---|
| 153 | 160 | 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; |
|---|
| 155 | 163 | return &ii->vfs_inode; |
|---|
| 156 | 164 | } |
|---|
| 157 | 165 | |
|---|
| 158 | | -static void nilfs_i_callback(struct rcu_head *head) |
|---|
| 166 | +static void nilfs_free_inode(struct inode *inode) |
|---|
| 159 | 167 | { |
|---|
| 160 | | - struct inode *inode = container_of(head, struct inode, i_rcu); |
|---|
| 161 | | - |
|---|
| 162 | 168 | if (nilfs_is_metadata_file_inode(inode)) |
|---|
| 163 | 169 | nilfs_mdt_destroy(inode); |
|---|
| 164 | 170 | |
|---|
| 165 | 171 | 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); |
|---|
| 171 | 172 | } |
|---|
| 172 | 173 | |
|---|
| 173 | 174 | static int nilfs_sync_super(struct super_block *sb, int flag) |
|---|
| .. | .. |
|---|
| 185 | 186 | } |
|---|
| 186 | 187 | |
|---|
| 187 | 188 | 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); |
|---|
| 190 | 190 | if (err == -EIO && nilfs->ns_sbh[1]) { |
|---|
| 191 | 191 | /* |
|---|
| 192 | 192 | * sbp[0] points to newer log than sbp[1], |
|---|
| .. | .. |
|---|
| 256 | 256 | sbp[1]->s_magic == cpu_to_le16(NILFS_SUPER_MAGIC)) { |
|---|
| 257 | 257 | memcpy(sbp[0], sbp[1], nilfs->ns_sbsize); |
|---|
| 258 | 258 | } else { |
|---|
| 259 | | - nilfs_msg(sb, KERN_CRIT, "superblock broke"); |
|---|
| 259 | + nilfs_crit(sb, "superblock broke"); |
|---|
| 260 | 260 | return NULL; |
|---|
| 261 | 261 | } |
|---|
| 262 | 262 | } else if (sbp[1] && |
|---|
| .. | .. |
|---|
| 366 | 366 | offset = sb2off & (nilfs->ns_blocksize - 1); |
|---|
| 367 | 367 | nsbh = sb_getblk(sb, newblocknr); |
|---|
| 368 | 368 | 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); |
|---|
| 372 | 372 | ret = -EIO; |
|---|
| 373 | 373 | goto out; |
|---|
| 374 | 374 | } |
|---|
| .. | .. |
|---|
| 531 | 531 | up_read(&nilfs->ns_segctor_sem); |
|---|
| 532 | 532 | if (unlikely(err)) { |
|---|
| 533 | 533 | if (err == -ENOENT || err == -EINVAL) { |
|---|
| 534 | | - nilfs_msg(sb, KERN_ERR, |
|---|
| 534 | + nilfs_err(sb, |
|---|
| 535 | 535 | "Invalid checkpoint (checkpoint number=%llu)", |
|---|
| 536 | 536 | (unsigned long long)cno); |
|---|
| 537 | 537 | err = -EINVAL; |
|---|
| .. | .. |
|---|
| 629 | 629 | err = nilfs_ifile_count_free_inodes(root->ifile, |
|---|
| 630 | 630 | &nmaxinodes, &nfreeinodes); |
|---|
| 631 | 631 | 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); |
|---|
| 634 | 633 | if (err == -ERANGE) { |
|---|
| 635 | 634 | /* |
|---|
| 636 | 635 | * If nilfs_palloc_count_max_entries() returns |
|---|
| .. | .. |
|---|
| 654 | 653 | buf->f_files = nmaxinodes; |
|---|
| 655 | 654 | buf->f_ffree = nfreeinodes; |
|---|
| 656 | 655 | 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); |
|---|
| 659 | 657 | |
|---|
| 660 | 658 | return 0; |
|---|
| 661 | 659 | } |
|---|
| .. | .. |
|---|
| 686 | 684 | |
|---|
| 687 | 685 | static const struct super_operations nilfs_sops = { |
|---|
| 688 | 686 | .alloc_inode = nilfs_alloc_inode, |
|---|
| 689 | | - .destroy_inode = nilfs_destroy_inode, |
|---|
| 687 | + .free_inode = nilfs_free_inode, |
|---|
| 690 | 688 | .dirty_inode = nilfs_dirty_inode, |
|---|
| 691 | 689 | .evict_inode = nilfs_evict_inode, |
|---|
| 692 | 690 | .put_super = nilfs_put_super, |
|---|
| .. | .. |
|---|
| 762 | 760 | break; |
|---|
| 763 | 761 | case Opt_snapshot: |
|---|
| 764 | 762 | if (is_remount) { |
|---|
| 765 | | - nilfs_msg(sb, KERN_ERR, |
|---|
| 763 | + nilfs_err(sb, |
|---|
| 766 | 764 | "\"%s\" option is invalid for remount", |
|---|
| 767 | 765 | p); |
|---|
| 768 | 766 | return 0; |
|---|
| .. | .. |
|---|
| 778 | 776 | nilfs_clear_opt(nilfs, DISCARD); |
|---|
| 779 | 777 | break; |
|---|
| 780 | 778 | default: |
|---|
| 781 | | - nilfs_msg(sb, KERN_ERR, |
|---|
| 782 | | - "unrecognized mount option \"%s\"", p); |
|---|
| 779 | + nilfs_err(sb, "unrecognized mount option \"%s\"", p); |
|---|
| 783 | 780 | return 0; |
|---|
| 784 | 781 | } |
|---|
| 785 | 782 | } |
|---|
| .. | .. |
|---|
| 815 | 812 | mnt_count = le16_to_cpu(sbp[0]->s_mnt_count); |
|---|
| 816 | 813 | |
|---|
| 817 | 814 | 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"); |
|---|
| 819 | 816 | #if 0 |
|---|
| 820 | 817 | } 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"); |
|---|
| 822 | 819 | #endif |
|---|
| 823 | 820 | } |
|---|
| 824 | 821 | if (!max_mnt_count) |
|---|
| .. | .. |
|---|
| 881 | 878 | features = le64_to_cpu(sbp->s_feature_incompat) & |
|---|
| 882 | 879 | ~NILFS_FEATURE_INCOMPAT_SUPP; |
|---|
| 883 | 880 | if (features) { |
|---|
| 884 | | - nilfs_msg(sb, KERN_ERR, |
|---|
| 881 | + nilfs_err(sb, |
|---|
| 885 | 882 | "couldn't mount because of unsupported optional features (%llx)", |
|---|
| 886 | 883 | (unsigned long long)features); |
|---|
| 887 | 884 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 889 | 886 | features = le64_to_cpu(sbp->s_feature_compat_ro) & |
|---|
| 890 | 887 | ~NILFS_FEATURE_COMPAT_RO_SUPP; |
|---|
| 891 | 888 | if (!sb_rdonly(sb) && features) { |
|---|
| 892 | | - nilfs_msg(sb, KERN_ERR, |
|---|
| 889 | + nilfs_err(sb, |
|---|
| 893 | 890 | "couldn't mount RDWR because of unsupported optional features (%llx)", |
|---|
| 894 | 891 | (unsigned long long)features); |
|---|
| 895 | 892 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 908 | 905 | inode = nilfs_iget(sb, root, NILFS_ROOT_INO); |
|---|
| 909 | 906 | if (IS_ERR(inode)) { |
|---|
| 910 | 907 | 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); |
|---|
| 912 | 909 | goto out; |
|---|
| 913 | 910 | } |
|---|
| 914 | 911 | if (!S_ISDIR(inode->i_mode) || !inode->i_blocks || !inode->i_size) { |
|---|
| 915 | 912 | iput(inode); |
|---|
| 916 | | - nilfs_msg(sb, KERN_ERR, "corrupt root inode"); |
|---|
| 913 | + nilfs_err(sb, "corrupt root inode"); |
|---|
| 917 | 914 | ret = -EINVAL; |
|---|
| 918 | 915 | goto out; |
|---|
| 919 | 916 | } |
|---|
| .. | .. |
|---|
| 941 | 938 | return ret; |
|---|
| 942 | 939 | |
|---|
| 943 | 940 | failed_dentry: |
|---|
| 944 | | - nilfs_msg(sb, KERN_ERR, "error %d getting root dentry", ret); |
|---|
| 941 | + nilfs_err(sb, "error %d getting root dentry", ret); |
|---|
| 945 | 942 | goto out; |
|---|
| 946 | 943 | } |
|---|
| 947 | 944 | |
|---|
| .. | .. |
|---|
| 961 | 958 | ret = (ret == -ENOENT) ? -EINVAL : ret; |
|---|
| 962 | 959 | goto out; |
|---|
| 963 | 960 | } else if (!ret) { |
|---|
| 964 | | - nilfs_msg(s, KERN_ERR, |
|---|
| 961 | + nilfs_err(s, |
|---|
| 965 | 962 | "The specified checkpoint is not a snapshot (checkpoint number=%llu)", |
|---|
| 966 | 963 | (unsigned long long)cno); |
|---|
| 967 | 964 | ret = -EINVAL; |
|---|
| .. | .. |
|---|
| 970 | 967 | |
|---|
| 971 | 968 | ret = nilfs_attach_checkpoint(s, cno, false, &root); |
|---|
| 972 | 969 | if (ret) { |
|---|
| 973 | | - nilfs_msg(s, KERN_ERR, |
|---|
| 970 | + nilfs_err(s, |
|---|
| 974 | 971 | "error %d while loading snapshot (checkpoint number=%llu)", |
|---|
| 975 | 972 | ret, (unsigned long long)cno); |
|---|
| 976 | 973 | goto out; |
|---|
| .. | .. |
|---|
| 1067 | 1064 | cno = nilfs_last_cno(nilfs); |
|---|
| 1068 | 1065 | err = nilfs_attach_checkpoint(sb, cno, true, &fsroot); |
|---|
| 1069 | 1066 | if (err) { |
|---|
| 1070 | | - nilfs_msg(sb, KERN_ERR, |
|---|
| 1067 | + nilfs_err(sb, |
|---|
| 1071 | 1068 | "error %d while loading last checkpoint (checkpoint number=%llu)", |
|---|
| 1072 | 1069 | err, (unsigned long long)cno); |
|---|
| 1073 | 1070 | goto failed_unload; |
|---|
| .. | .. |
|---|
| 1129 | 1126 | err = -EINVAL; |
|---|
| 1130 | 1127 | |
|---|
| 1131 | 1128 | 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"); |
|---|
| 1134 | 1131 | goto restore_opts; |
|---|
| 1135 | 1132 | } |
|---|
| 1136 | 1133 | |
|---|
| 1137 | 1134 | if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb)) |
|---|
| 1138 | 1135 | goto out; |
|---|
| 1139 | 1136 | if (*flags & SB_RDONLY) { |
|---|
| 1140 | | - /* Shutting down log writer */ |
|---|
| 1141 | | - nilfs_detach_log_writer(sb); |
|---|
| 1142 | 1137 | sb->s_flags |= SB_RDONLY; |
|---|
| 1143 | 1138 | |
|---|
| 1144 | 1139 | /* |
|---|
| .. | .. |
|---|
| 1162 | 1157 | ~NILFS_FEATURE_COMPAT_RO_SUPP; |
|---|
| 1163 | 1158 | up_read(&nilfs->ns_sem); |
|---|
| 1164 | 1159 | 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); |
|---|
| 1168 | 1163 | err = -EROFS; |
|---|
| 1169 | 1164 | goto restore_opts; |
|---|
| 1170 | 1165 | } |
|---|
| .. | .. |
|---|
| 1223 | 1218 | return 0; |
|---|
| 1224 | 1219 | |
|---|
| 1225 | 1220 | parse_error: |
|---|
| 1226 | | - nilfs_msg(NULL, KERN_ERR, "invalid option \"%s\": %s", option, msg); |
|---|
| 1221 | + nilfs_err(NULL, "invalid option \"%s\": %s", option, msg); |
|---|
| 1227 | 1222 | return 1; |
|---|
| 1228 | 1223 | } |
|---|
| 1229 | 1224 | |
|---|
| .. | .. |
|---|
| 1326 | 1321 | } else if (!sd.cno) { |
|---|
| 1327 | 1322 | if (nilfs_tree_is_busy(s->s_root)) { |
|---|
| 1328 | 1323 | if ((flags ^ s->s_flags) & SB_RDONLY) { |
|---|
| 1329 | | - nilfs_msg(s, KERN_ERR, |
|---|
| 1324 | + nilfs_err(s, |
|---|
| 1330 | 1325 | "the device already has a %s mount.", |
|---|
| 1331 | 1326 | sb_rdonly(s) ? "read-only" : "read/write"); |
|---|
| 1332 | 1327 | err = -EBUSY; |
|---|
| .. | .. |
|---|
| 1382 | 1377 | #ifdef CONFIG_NILFS_XATTR |
|---|
| 1383 | 1378 | init_rwsem(&ii->xattr_sem); |
|---|
| 1384 | 1379 | #endif |
|---|
| 1385 | | - address_space_init_once(&ii->i_btnode_cache); |
|---|
| 1386 | | - ii->i_bmap = &ii->i_bmap_data; |
|---|
| 1387 | 1380 | inode_init_once(&ii->vfs_inode); |
|---|
| 1388 | 1381 | } |
|---|
| 1389 | 1382 | |
|---|