1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * fs/f2fs/namei.c 4 * 5 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 6 * http://www.samsung.com/ 7 */ 8 #include <linux/fs.h> 9 #include <linux/f2fs_fs.h> 10 #include <linux/pagemap.h> 11 #include <linux/sched.h> 12 #include <linux/ctype.h> 13 #include <linux/random.h> 14 #include <linux/dcache.h> 15 #include <linux/namei.h> 16 #include <linux/quotaops.h> 17 18 #include "f2fs.h" 19 #include "node.h" 20 #include "segment.h" 21 #include "xattr.h" 22 #include "acl.h" 23 #include <trace/events/f2fs.h> 24 25 static inline bool is_extension_exist(const unsigned char *s, const char *sub, 26 bool tmp_ext, bool tmp_dot) 27 { 28 size_t slen = strlen(s); 29 size_t sublen = strlen(sub); 30 int i; 31 32 if (sublen == 1 && *sub == '*') 33 return true; 34 35 /* 36 * filename format of multimedia file should be defined as: 37 * "filename + '.' + extension + (optional: '.' + temp extension)". 38 */ 39 if (slen < sublen + 2) 40 return false; 41 42 if (!tmp_ext) { 43 /* file has no temp extension */ 44 if (s[slen - sublen - 1] != '.') 45 return false; 46 return !strncasecmp(s + slen - sublen, sub, sublen); 47 } 48 49 for (i = 1; i < slen - sublen; i++) { 50 if (s[i] != '.') 51 continue; 52 if (!strncasecmp(s + i + 1, sub, sublen)) { 53 if (!tmp_dot) 54 return true; 55 if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.') 56 return true; 57 } 58 } 59 60 return false; 61 } 62 63 static inline bool is_temperature_extension(const unsigned char *s, const char *sub) 64 { 65 return is_extension_exist(s, sub, true, false); 66 } 67 68 static inline bool is_compress_extension(const unsigned char *s, const char *sub) 69 { 70 return is_extension_exist(s, sub, true, true); 71 } 72 73 int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name, 74 bool hot, bool set) 75 { 76 __u8 (*extlist)[F2FS_EXTENSION_LEN] = sbi->raw_super->extension_list; 77 int cold_count = le32_to_cpu(sbi->raw_super->extension_count); 78 int hot_count = sbi->raw_super->hot_ext_count; 79 int total_count = cold_count + hot_count; 80 int start, count; 81 int i; 82 83 if (set) { 84 if (total_count == F2FS_MAX_EXTENSION) 85 return -EINVAL; 86 } else { 87 if (!hot && !cold_count) 88 return -EINVAL; 89 if (hot && !hot_count) 90 return -EINVAL; 91 } 92 93 if (hot) { 94 start = cold_count; 95 count = total_count; 96 } else { 97 start = 0; 98 count = cold_count; 99 } 100 101 for (i = start; i < count; i++) { 102 if (strcmp(name, extlist[i])) 103 continue; 104 105 if (set) 106 return -EINVAL; 107 108 memcpy(extlist[i], extlist[i + 1], 109 F2FS_EXTENSION_LEN * (total_count - i - 1)); 110 memset(extlist[total_count - 1], 0, F2FS_EXTENSION_LEN); 111 if (hot) 112 sbi->raw_super->hot_ext_count = hot_count - 1; 113 else 114 sbi->raw_super->extension_count = 115 cpu_to_le32(cold_count - 1); 116 return 0; 117 } 118 119 if (!set) 120 return -EINVAL; 121 122 if (hot) { 123 memcpy(extlist[count], name, strlen(name)); 124 sbi->raw_super->hot_ext_count = hot_count + 1; 125 } else { 126 char buf[F2FS_MAX_EXTENSION][F2FS_EXTENSION_LEN]; 127 128 memcpy(buf, &extlist[cold_count], 129 F2FS_EXTENSION_LEN * hot_count); 130 memset(extlist[cold_count], 0, F2FS_EXTENSION_LEN); 131 memcpy(extlist[cold_count], name, strlen(name)); 132 memcpy(&extlist[cold_count + 1], buf, 133 F2FS_EXTENSION_LEN * hot_count); 134 sbi->raw_super->extension_count = cpu_to_le32(cold_count + 1); 135 } 136 return 0; 137 } 138 139 static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir, 140 struct inode *inode, const unsigned char *name) 141 { 142 __u8 (*extlist)[F2FS_EXTENSION_LEN] = sbi->raw_super->extension_list; 143 unsigned char (*noext)[F2FS_EXTENSION_LEN] = 144 F2FS_OPTION(sbi).noextensions; 145 unsigned char (*ext)[F2FS_EXTENSION_LEN] = F2FS_OPTION(sbi).extensions; 146 unsigned char ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt; 147 unsigned char noext_cnt = F2FS_OPTION(sbi).nocompress_ext_cnt; 148 int i, cold_count, hot_count; 149 150 if (!f2fs_sb_has_compression(sbi)) 151 return; 152 153 if (S_ISDIR(inode->i_mode)) 154 goto inherit_comp; 155 156 /* This name comes only from normal files. */ 157 if (!name) 158 return; 159 160 /* Don't compress hot files. */ 161 f2fs_down_read(&sbi->sb_lock); 162 cold_count = le32_to_cpu(sbi->raw_super->extension_count); 163 hot_count = sbi->raw_super->hot_ext_count; 164 for (i = cold_count; i < cold_count + hot_count; i++) 165 if (is_temperature_extension(name, extlist[i])) 166 break; 167 f2fs_up_read(&sbi->sb_lock); 168 if (i < (cold_count + hot_count)) 169 return; 170 171 /* Don't compress unallowed extension. */ 172 for (i = 0; i < noext_cnt; i++) 173 if (is_compress_extension(name, noext[i])) 174 return; 175 176 /* Compress wanting extension. */ 177 for (i = 0; i < ext_cnt; i++) { 178 if (is_compress_extension(name, ext[i])) { 179 set_compress_context(inode); 180 return; 181 } 182 } 183 inherit_comp: 184 /* Inherit the {no-}compression flag in directory */ 185 if (F2FS_I(dir)->i_flags & F2FS_NOCOMP_FL) { 186 F2FS_I(inode)->i_flags |= F2FS_NOCOMP_FL; 187 f2fs_mark_inode_dirty_sync(inode, true); 188 } else if (F2FS_I(dir)->i_flags & F2FS_COMPR_FL) { 189 set_compress_context(inode); 190 } 191 } 192 193 /* 194 * Set file's temperature for hot/cold data separation 195 */ 196 static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode, 197 const unsigned char *name) 198 { 199 __u8 (*extlist)[F2FS_EXTENSION_LEN] = sbi->raw_super->extension_list; 200 int i, cold_count, hot_count; 201 202 f2fs_down_read(&sbi->sb_lock); 203 cold_count = le32_to_cpu(sbi->raw_super->extension_count); 204 hot_count = sbi->raw_super->hot_ext_count; 205 for (i = 0; i < cold_count + hot_count; i++) 206 if (is_temperature_extension(name, extlist[i])) 207 break; 208 f2fs_up_read(&sbi->sb_lock); 209 210 if (i == cold_count + hot_count) 211 return; 212 213 if (i < cold_count) 214 file_set_cold(inode); 215 else 216 file_set_hot(inode); 217 } 218 219 static struct inode *f2fs_new_inode(struct mnt_idmap *idmap, 220 struct inode *dir, umode_t mode, 221 const char *name) 222 { 223 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 224 struct f2fs_inode_info *fi; 225 nid_t ino; 226 struct inode *inode; 227 bool nid_free = false; 228 bool encrypt = false; 229 int xattr_size = 0; 230 int err; 231 232 inode = new_inode(dir->i_sb); 233 if (!inode) 234 return ERR_PTR(-ENOMEM); 235 236 if (!f2fs_alloc_nid(sbi, &ino)) { 237 err = -ENOSPC; 238 goto fail; 239 } 240 241 nid_free = true; 242 243 inode_init_owner(idmap, inode, dir, mode); 244 245 fi = F2FS_I(inode); 246 inode->i_ino = ino; 247 inode->i_blocks = 0; 248 simple_inode_init_ts(inode); 249 fi->i_crtime = inode_get_mtime(inode); 250 inode->i_generation = get_random_u32(); 251 252 if (S_ISDIR(inode->i_mode)) 253 fi->i_current_depth = 1; 254 255 err = insert_inode_locked(inode); 256 if (err) { 257 err = -EINVAL; 258 goto fail; 259 } 260 261 if (f2fs_sb_has_project_quota(sbi) && 262 (F2FS_I(dir)->i_flags & F2FS_PROJINHERIT_FL)) 263 fi->i_projid = F2FS_I(dir)->i_projid; 264 else 265 fi->i_projid = make_kprojid(&init_user_ns, 266 F2FS_DEF_PROJID); 267 268 err = fscrypt_prepare_new_inode(dir, inode, &encrypt); 269 if (err) 270 goto fail_drop; 271 272 err = f2fs_dquot_initialize(inode); 273 if (err) 274 goto fail_drop; 275 276 set_inode_flag(inode, FI_NEW_INODE); 277 278 if (encrypt) 279 f2fs_set_encrypted_inode(inode); 280 281 if (f2fs_sb_has_extra_attr(sbi)) { 282 set_inode_flag(inode, FI_EXTRA_ATTR); 283 fi->i_extra_isize = F2FS_TOTAL_EXTRA_ATTR_SIZE; 284 } 285 286 if (test_opt(sbi, INLINE_XATTR)) 287 set_inode_flag(inode, FI_INLINE_XATTR); 288 289 if (f2fs_may_inline_dentry(inode)) 290 set_inode_flag(inode, FI_INLINE_DENTRY); 291 292 if (f2fs_sb_has_flexible_inline_xattr(sbi)) { 293 f2fs_bug_on(sbi, !f2fs_has_extra_attr(inode)); 294 if (f2fs_has_inline_xattr(inode)) 295 xattr_size = F2FS_OPTION(sbi).inline_xattr_size; 296 /* Otherwise, will be 0 */ 297 } else if (f2fs_has_inline_xattr(inode) || 298 f2fs_has_inline_dentry(inode)) { 299 xattr_size = DEFAULT_INLINE_XATTR_ADDRS; 300 } 301 fi->i_inline_xattr_size = xattr_size; 302 303 fi->i_flags = 304 f2fs_mask_flags(mode, F2FS_I(dir)->i_flags & F2FS_FL_INHERITED); 305 306 if (S_ISDIR(inode->i_mode)) 307 fi->i_flags |= F2FS_INDEX_FL; 308 309 if (fi->i_flags & F2FS_PROJINHERIT_FL) 310 set_inode_flag(inode, FI_PROJ_INHERIT); 311 312 /* Check compression first. */ 313 set_compress_new_inode(sbi, dir, inode, name); 314 315 /* Should enable inline_data after compression set */ 316 if (test_opt(sbi, INLINE_DATA) && f2fs_may_inline_data(inode)) 317 set_inode_flag(inode, FI_INLINE_DATA); 318 319 if (name && !test_opt(sbi, DISABLE_EXT_IDENTIFY)) 320 set_file_temperature(sbi, inode, name); 321 322 stat_inc_inline_xattr(inode); 323 stat_inc_inline_inode(inode); 324 stat_inc_inline_dir(inode); 325 326 f2fs_set_inode_flags(inode); 327 328 f2fs_init_extent_tree(inode); 329 330 trace_f2fs_new_inode(inode, 0); 331 return inode; 332 333 fail: 334 trace_f2fs_new_inode(inode, err); 335 make_bad_inode(inode); 336 if (nid_free) 337 set_inode_flag(inode, FI_FREE_NID); 338 iput(inode); 339 return ERR_PTR(err); 340 fail_drop: 341 trace_f2fs_new_inode(inode, err); 342 dquot_drop(inode); 343 inode->i_flags |= S_NOQUOTA; 344 make_bad_inode(inode); 345 if (nid_free) 346 set_inode_flag(inode, FI_FREE_NID); 347 clear_nlink(inode); 348 unlock_new_inode(inode); 349 iput(inode); 350 return ERR_PTR(err); 351 } 352 353 static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir, 354 struct dentry *dentry, umode_t mode, bool excl) 355 { 356 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 357 struct f2fs_lock_context lc; 358 struct inode *inode; 359 nid_t ino = 0; 360 int err; 361 362 if (unlikely(f2fs_cp_error(sbi))) 363 return -EIO; 364 if (!f2fs_is_checkpoint_ready(sbi)) 365 return -ENOSPC; 366 367 err = f2fs_dquot_initialize(dir); 368 if (err) 369 return err; 370 371 inode = f2fs_new_inode(idmap, dir, mode, dentry->d_name.name); 372 if (IS_ERR(inode)) 373 return PTR_ERR(inode); 374 375 inode->i_op = &f2fs_file_inode_operations; 376 inode->i_fop = &f2fs_file_operations; 377 inode->i_mapping->a_ops = &f2fs_dblock_aops; 378 ino = inode->i_ino; 379 380 f2fs_lock_op(sbi, &lc); 381 err = f2fs_add_link(dentry, inode); 382 if (err) 383 goto out; 384 f2fs_unlock_op(sbi, &lc); 385 386 f2fs_alloc_nid_done(sbi, ino); 387 388 d_instantiate_new(dentry, inode); 389 390 if (IS_DIRSYNC(dir)) 391 f2fs_sync_fs(sbi->sb, 1); 392 393 f2fs_balance_fs(sbi, true); 394 return 0; 395 out: 396 f2fs_handle_failed_inode(inode, &lc); 397 return err; 398 } 399 400 static int f2fs_link(struct dentry *old_dentry, struct inode *dir, 401 struct dentry *dentry) 402 { 403 struct inode *inode = d_inode(old_dentry); 404 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 405 struct f2fs_lock_context lc; 406 int err; 407 408 if (unlikely(f2fs_cp_error(sbi))) 409 return -EIO; 410 if (!f2fs_is_checkpoint_ready(sbi)) 411 return -ENOSPC; 412 413 err = fscrypt_prepare_link(old_dentry, dir, dentry); 414 if (err) 415 return err; 416 417 if (is_inode_flag_set(dir, FI_PROJ_INHERIT) && 418 (!projid_eq(F2FS_I(dir)->i_projid, 419 F2FS_I(inode)->i_projid))) 420 return -EXDEV; 421 422 err = f2fs_dquot_initialize(dir); 423 if (err) 424 return err; 425 426 f2fs_balance_fs(sbi, true); 427 428 inode_set_ctime_current(inode); 429 ihold(inode); 430 431 set_inode_flag(inode, FI_INC_LINK); 432 f2fs_lock_op(sbi, &lc); 433 err = f2fs_add_link(dentry, inode); 434 if (err) 435 goto out; 436 f2fs_unlock_op(sbi, &lc); 437 438 d_instantiate(dentry, inode); 439 440 if (IS_DIRSYNC(dir)) 441 f2fs_sync_fs(sbi->sb, 1); 442 return 0; 443 out: 444 clear_inode_flag(inode, FI_INC_LINK); 445 iput(inode); 446 f2fs_unlock_op(sbi, &lc); 447 return err; 448 } 449 450 struct dentry *f2fs_get_parent(struct dentry *child) 451 { 452 struct folio *folio; 453 unsigned long ino = f2fs_inode_by_name(d_inode(child), &dotdot_name, &folio); 454 455 if (!ino) { 456 if (IS_ERR(folio)) 457 return ERR_CAST(folio); 458 return ERR_PTR(-ENOENT); 459 } 460 return d_obtain_alias(f2fs_iget(child->d_sb, ino)); 461 } 462 463 static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, 464 unsigned int flags) 465 { 466 struct inode *inode = NULL; 467 struct f2fs_dir_entry *de; 468 struct folio *folio; 469 struct dentry *new; 470 nid_t ino = -1; 471 int err = 0; 472 struct f2fs_filename fname; 473 474 trace_f2fs_lookup_start(dir, dentry, flags); 475 476 if (dentry->d_name.len > F2FS_NAME_LEN) { 477 err = -ENAMETOOLONG; 478 goto out; 479 } 480 481 err = f2fs_prepare_lookup(dir, dentry, &fname); 482 if (err == -ENOENT) 483 goto out_splice; 484 if (err) 485 goto out; 486 de = __f2fs_find_entry(dir, &fname, &folio); 487 f2fs_free_filename(&fname); 488 489 if (!de) { 490 if (IS_ERR(folio)) { 491 err = PTR_ERR(folio); 492 goto out; 493 } 494 err = -ENOENT; 495 goto out_splice; 496 } 497 498 ino = le32_to_cpu(de->ino); 499 f2fs_folio_put(folio, false); 500 501 inode = f2fs_iget(dir->i_sb, ino); 502 if (IS_ERR(inode)) { 503 err = PTR_ERR(inode); 504 goto out; 505 } 506 507 if (inode->i_nlink == 0) { 508 f2fs_warn(F2FS_I_SB(inode), "%s: inode (ino=%lx) has zero i_nlink", 509 __func__, inode->i_ino); 510 err = -EFSCORRUPTED; 511 set_sbi_flag(F2FS_I_SB(inode), SBI_NEED_FSCK); 512 goto out_iput; 513 } 514 515 if (IS_ENCRYPTED(dir) && 516 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && 517 !fscrypt_has_permitted_context(dir, inode)) { 518 f2fs_warn(F2FS_I_SB(inode), "Inconsistent encryption contexts: %lu/%lu", 519 dir->i_ino, inode->i_ino); 520 err = -EPERM; 521 goto out_iput; 522 } 523 out_splice: 524 if (IS_ENABLED(CONFIG_UNICODE) && !inode && IS_CASEFOLDED(dir)) { 525 /* Eventually we want to call d_add_ci(dentry, NULL) 526 * for negative dentries in the encoding case as 527 * well. For now, prevent the negative dentry 528 * from being cached. 529 */ 530 trace_f2fs_lookup_end(dir, dentry, ino, err); 531 return NULL; 532 } 533 534 new = d_splice_alias(inode, dentry); 535 trace_f2fs_lookup_end(dir, !IS_ERR_OR_NULL(new) ? new : dentry, 536 ino, IS_ERR(new) ? PTR_ERR(new) : err); 537 return new; 538 out_iput: 539 iput(inode); 540 out: 541 trace_f2fs_lookup_end(dir, dentry, ino, err); 542 return ERR_PTR(err); 543 } 544 545 static int f2fs_unlink(struct inode *dir, struct dentry *dentry) 546 { 547 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 548 struct inode *inode = d_inode(dentry); 549 struct f2fs_dir_entry *de; 550 struct f2fs_lock_context lc; 551 struct folio *folio; 552 int err; 553 554 trace_f2fs_unlink_enter(dir, dentry); 555 556 if (unlikely(f2fs_cp_error(sbi))) { 557 err = -EIO; 558 goto out; 559 } 560 561 err = f2fs_dquot_initialize(dir); 562 if (err) 563 goto out; 564 err = f2fs_dquot_initialize(inode); 565 if (err) 566 goto out; 567 568 de = f2fs_find_entry(dir, &dentry->d_name, &folio); 569 if (!de) { 570 if (IS_ERR(folio)) 571 err = PTR_ERR(folio); 572 goto out; 573 } 574 575 if (unlikely(inode->i_nlink == 0)) { 576 f2fs_warn(sbi, "%s: inode (ino=%lx) has zero i_nlink", 577 __func__, inode->i_ino); 578 goto corrupted; 579 } else if (S_ISDIR(inode->i_mode) && unlikely(inode->i_nlink == 1)) { 580 f2fs_warn(sbi, "%s: directory inode (ino=%lx) has a single i_nlink", 581 __func__, inode->i_ino); 582 goto corrupted; 583 } 584 585 f2fs_balance_fs(sbi, true); 586 587 f2fs_lock_op(sbi, &lc); 588 err = f2fs_acquire_orphan_inode(sbi); 589 if (err) { 590 f2fs_unlock_op(sbi, &lc); 591 f2fs_folio_put(folio, false); 592 goto out; 593 } 594 f2fs_delete_entry(de, folio, dir, inode); 595 f2fs_unlock_op(sbi, &lc); 596 597 /* VFS negative dentries are incompatible with Encoding and 598 * Case-insensitiveness. Eventually we'll want avoid 599 * invalidating the dentries here, alongside with returning the 600 * negative dentries at f2fs_lookup(), when it is better 601 * supported by the VFS for the CI case. 602 */ 603 if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) 604 d_invalidate(dentry); 605 606 if (IS_DIRSYNC(dir)) 607 f2fs_sync_fs(sbi->sb, 1); 608 609 goto out; 610 corrupted: 611 err = -EFSCORRUPTED; 612 set_sbi_flag(sbi, SBI_NEED_FSCK); 613 f2fs_folio_put(folio, false); 614 out: 615 trace_f2fs_unlink_exit(inode, err); 616 return err; 617 } 618 619 static const char *f2fs_get_link(struct dentry *dentry, 620 struct inode *inode, 621 struct delayed_call *done) 622 { 623 const char *link = page_get_link(dentry, inode, done); 624 625 if (!IS_ERR(link) && !*link) { 626 /* this is broken symlink case */ 627 do_delayed_call(done); 628 clear_delayed_call(done); 629 link = ERR_PTR(-ENOENT); 630 } 631 return link; 632 } 633 634 static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir, 635 struct dentry *dentry, const char *symname) 636 { 637 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 638 struct f2fs_lock_context lc; 639 struct inode *inode; 640 size_t len = strlen(symname); 641 struct fscrypt_str disk_link; 642 int err; 643 644 if (unlikely(f2fs_cp_error(sbi))) 645 return -EIO; 646 if (!f2fs_is_checkpoint_ready(sbi)) 647 return -ENOSPC; 648 649 err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize, 650 &disk_link); 651 if (err) 652 return err; 653 654 err = f2fs_dquot_initialize(dir); 655 if (err) 656 return err; 657 658 inode = f2fs_new_inode(idmap, dir, S_IFLNK | S_IRWXUGO, NULL); 659 if (IS_ERR(inode)) 660 return PTR_ERR(inode); 661 662 if (IS_ENCRYPTED(inode)) 663 inode->i_op = &f2fs_encrypted_symlink_inode_operations; 664 else 665 inode->i_op = &f2fs_symlink_inode_operations; 666 inode_nohighmem(inode); 667 inode->i_mapping->a_ops = &f2fs_dblock_aops; 668 669 f2fs_lock_op(sbi, &lc); 670 err = f2fs_add_link(dentry, inode); 671 if (err) 672 goto out_f2fs_handle_failed_inode; 673 f2fs_unlock_op(sbi, &lc); 674 f2fs_alloc_nid_done(sbi, inode->i_ino); 675 676 err = fscrypt_encrypt_symlink(inode, symname, len, &disk_link); 677 if (err) 678 goto err_out; 679 680 err = page_symlink(inode, disk_link.name, disk_link.len); 681 682 err_out: 683 d_instantiate_new(dentry, inode); 684 685 /* 686 * Let's flush symlink data in order to avoid broken symlink as much as 687 * possible. Nevertheless, fsyncing is the best way, but there is no 688 * way to get a file descriptor in order to flush that. 689 * 690 * Note that, it needs to do dir->fsync to make this recoverable. 691 * If the symlink path is stored into inline_data, there is no 692 * performance regression. 693 */ 694 if (!err) { 695 filemap_write_and_wait_range(inode->i_mapping, 0, 696 disk_link.len - 1); 697 698 if (IS_DIRSYNC(dir)) 699 f2fs_sync_fs(sbi->sb, 1); 700 } else { 701 f2fs_unlink(dir, dentry); 702 } 703 704 f2fs_balance_fs(sbi, true); 705 goto out_free_encrypted_link; 706 707 out_f2fs_handle_failed_inode: 708 f2fs_handle_failed_inode(inode, &lc); 709 out_free_encrypted_link: 710 if (disk_link.name != (unsigned char *)symname) 711 kfree(disk_link.name); 712 return err; 713 } 714 715 static struct dentry *f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir, 716 struct dentry *dentry, umode_t mode) 717 { 718 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 719 struct f2fs_lock_context lc; 720 struct inode *inode; 721 int err; 722 723 if (unlikely(f2fs_cp_error(sbi))) 724 return ERR_PTR(-EIO); 725 726 err = f2fs_dquot_initialize(dir); 727 if (err) 728 return ERR_PTR(err); 729 730 inode = f2fs_new_inode(idmap, dir, S_IFDIR | mode, NULL); 731 if (IS_ERR(inode)) 732 return ERR_CAST(inode); 733 734 inode->i_op = &f2fs_dir_inode_operations; 735 inode->i_fop = &f2fs_dir_operations; 736 inode->i_mapping->a_ops = &f2fs_dblock_aops; 737 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS); 738 739 set_inode_flag(inode, FI_INC_LINK); 740 f2fs_lock_op(sbi, &lc); 741 err = f2fs_add_link(dentry, inode); 742 if (err) 743 goto out_fail; 744 f2fs_unlock_op(sbi, &lc); 745 746 f2fs_alloc_nid_done(sbi, inode->i_ino); 747 748 d_instantiate_new(dentry, inode); 749 750 if (IS_DIRSYNC(dir)) 751 f2fs_sync_fs(sbi->sb, 1); 752 753 f2fs_balance_fs(sbi, true); 754 return NULL; 755 756 out_fail: 757 clear_inode_flag(inode, FI_INC_LINK); 758 f2fs_handle_failed_inode(inode, &lc); 759 return ERR_PTR(err); 760 } 761 762 static int f2fs_rmdir(struct inode *dir, struct dentry *dentry) 763 { 764 struct inode *inode = d_inode(dentry); 765 766 if (f2fs_empty_dir(inode)) 767 return f2fs_unlink(dir, dentry); 768 return -ENOTEMPTY; 769 } 770 771 static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir, 772 struct dentry *dentry, umode_t mode, dev_t rdev) 773 { 774 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 775 struct f2fs_lock_context lc; 776 struct inode *inode; 777 int err = 0; 778 779 if (unlikely(f2fs_cp_error(sbi))) 780 return -EIO; 781 if (!f2fs_is_checkpoint_ready(sbi)) 782 return -ENOSPC; 783 784 err = f2fs_dquot_initialize(dir); 785 if (err) 786 return err; 787 788 inode = f2fs_new_inode(idmap, dir, mode, NULL); 789 if (IS_ERR(inode)) 790 return PTR_ERR(inode); 791 792 init_special_inode(inode, inode->i_mode, rdev); 793 inode->i_op = &f2fs_special_inode_operations; 794 795 f2fs_lock_op(sbi, &lc); 796 err = f2fs_add_link(dentry, inode); 797 if (err) 798 goto out; 799 f2fs_unlock_op(sbi, &lc); 800 801 f2fs_alloc_nid_done(sbi, inode->i_ino); 802 803 d_instantiate_new(dentry, inode); 804 805 if (IS_DIRSYNC(dir)) 806 f2fs_sync_fs(sbi->sb, 1); 807 808 f2fs_balance_fs(sbi, true); 809 return 0; 810 out: 811 f2fs_handle_failed_inode(inode, &lc); 812 return err; 813 } 814 815 static int __f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir, 816 struct file *file, umode_t mode, bool is_whiteout, 817 struct inode **new_inode, struct f2fs_filename *fname) 818 { 819 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 820 struct f2fs_lock_context lc; 821 struct inode *inode; 822 int err; 823 824 err = f2fs_dquot_initialize(dir); 825 if (err) 826 return err; 827 828 inode = f2fs_new_inode(idmap, dir, mode, NULL); 829 if (IS_ERR(inode)) 830 return PTR_ERR(inode); 831 832 if (is_whiteout) { 833 init_special_inode(inode, inode->i_mode, WHITEOUT_DEV); 834 inode->i_op = &f2fs_special_inode_operations; 835 } else { 836 inode->i_op = &f2fs_file_inode_operations; 837 inode->i_fop = &f2fs_file_operations; 838 inode->i_mapping->a_ops = &f2fs_dblock_aops; 839 } 840 841 f2fs_lock_op(sbi, &lc); 842 err = f2fs_acquire_orphan_inode(sbi); 843 if (err) 844 goto out; 845 846 err = f2fs_do_tmpfile(inode, dir, fname); 847 if (err) 848 goto release_out; 849 850 /* 851 * add this non-linked tmpfile to orphan list, in this way we could 852 * remove all unused data of tmpfile after abnormal power-off. 853 */ 854 f2fs_add_orphan_inode(inode); 855 f2fs_alloc_nid_done(sbi, inode->i_ino); 856 857 if (is_whiteout) { 858 f2fs_i_links_write(inode, false); 859 860 spin_lock(&inode->i_lock); 861 inode_state_set(inode, I_LINKABLE); 862 spin_unlock(&inode->i_lock); 863 } else { 864 if (file) 865 d_tmpfile(file, inode); 866 else 867 f2fs_i_links_write(inode, false); 868 } 869 /* link_count was changed by d_tmpfile as well. */ 870 f2fs_unlock_op(sbi, &lc); 871 unlock_new_inode(inode); 872 873 if (new_inode) 874 *new_inode = inode; 875 876 f2fs_balance_fs(sbi, true); 877 return 0; 878 879 release_out: 880 f2fs_release_orphan_inode(sbi); 881 out: 882 f2fs_handle_failed_inode(inode, &lc); 883 return err; 884 } 885 886 static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir, 887 struct file *file, umode_t mode) 888 { 889 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); 890 int err; 891 892 if (unlikely(f2fs_cp_error(sbi))) 893 return -EIO; 894 if (!f2fs_is_checkpoint_ready(sbi)) 895 return -ENOSPC; 896 897 err = __f2fs_tmpfile(idmap, dir, file, mode, false, NULL, NULL); 898 899 return finish_open_simple(file, err); 900 } 901 902 static int f2fs_create_whiteout(struct mnt_idmap *idmap, 903 struct inode *dir, struct inode **whiteout, 904 struct f2fs_filename *fname) 905 { 906 return __f2fs_tmpfile(idmap, dir, NULL, S_IFCHR | WHITEOUT_MODE, 907 true, whiteout, fname); 908 } 909 910 int f2fs_get_tmpfile(struct mnt_idmap *idmap, struct inode *dir, 911 struct inode **new_inode) 912 { 913 return __f2fs_tmpfile(idmap, dir, NULL, S_IFREG, 914 false, new_inode, NULL); 915 } 916 917 static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, 918 struct dentry *old_dentry, struct inode *new_dir, 919 struct dentry *new_dentry, unsigned int flags) 920 { 921 struct f2fs_sb_info *sbi = F2FS_I_SB(old_dir); 922 struct inode *old_inode = d_inode(old_dentry); 923 struct inode *new_inode = d_inode(new_dentry); 924 struct inode *whiteout = NULL; 925 struct folio *old_dir_folio = NULL; 926 struct folio *old_folio, *new_folio = NULL; 927 struct f2fs_dir_entry *old_dir_entry = NULL; 928 struct f2fs_dir_entry *old_entry; 929 struct f2fs_dir_entry *new_entry; 930 struct f2fs_lock_context lc; 931 bool old_is_dir = S_ISDIR(old_inode->i_mode); 932 int err; 933 934 if (unlikely(f2fs_cp_error(sbi))) 935 return -EIO; 936 if (!f2fs_is_checkpoint_ready(sbi)) 937 return -ENOSPC; 938 939 if (is_inode_flag_set(new_dir, FI_PROJ_INHERIT) && 940 (!projid_eq(F2FS_I(new_dir)->i_projid, 941 F2FS_I(old_inode)->i_projid))) 942 return -EXDEV; 943 944 /* 945 * If new_inode is null, the below renaming flow will 946 * add a link in old_dir which can convert inline_dir. 947 * After then, if we failed to get the entry due to other 948 * reasons like ENOMEM, we had to remove the new entry. 949 * Instead of adding such the error handling routine, let's 950 * simply convert first here. 951 */ 952 if (old_dir == new_dir && !new_inode) { 953 err = f2fs_try_convert_inline_dir(old_dir, new_dentry); 954 if (err) 955 return err; 956 } 957 958 if (flags & RENAME_WHITEOUT) { 959 struct f2fs_filename fname; 960 961 err = f2fs_setup_filename(old_dir, &old_dentry->d_name, 962 0, &fname); 963 if (err) 964 return err; 965 966 err = f2fs_create_whiteout(idmap, old_dir, &whiteout, &fname); 967 if (err) 968 return err; 969 } 970 971 err = f2fs_dquot_initialize(old_dir); 972 if (err) 973 goto out; 974 975 err = f2fs_dquot_initialize(new_dir); 976 if (err) 977 goto out; 978 979 if (new_inode) { 980 err = f2fs_dquot_initialize(new_inode); 981 if (err) 982 goto out; 983 } 984 985 err = -ENOENT; 986 old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_folio); 987 if (!old_entry) { 988 if (IS_ERR(old_folio)) 989 err = PTR_ERR(old_folio); 990 goto out; 991 } 992 993 if (old_is_dir && old_dir != new_dir) { 994 old_dir_entry = f2fs_parent_dir(old_inode, &old_dir_folio); 995 if (!old_dir_entry) { 996 if (IS_ERR(old_dir_folio)) 997 err = PTR_ERR(old_dir_folio); 998 goto out_old; 999 } 1000 } 1001 1002 if (new_inode) { 1003 1004 err = -ENOTEMPTY; 1005 if (old_is_dir && !f2fs_empty_dir(new_inode)) 1006 goto out_dir; 1007 1008 err = -ENOENT; 1009 new_entry = f2fs_find_entry(new_dir, &new_dentry->d_name, 1010 &new_folio); 1011 if (!new_entry) { 1012 if (IS_ERR(new_folio)) 1013 err = PTR_ERR(new_folio); 1014 goto out_dir; 1015 } 1016 1017 f2fs_balance_fs(sbi, true); 1018 1019 f2fs_lock_op(sbi, &lc); 1020 1021 err = f2fs_acquire_orphan_inode(sbi); 1022 if (err) 1023 goto put_out_dir; 1024 1025 f2fs_set_link(new_dir, new_entry, new_folio, old_inode); 1026 new_folio = NULL; 1027 1028 inode_set_ctime_current(new_inode); 1029 f2fs_down_write(&F2FS_I(new_inode)->i_sem); 1030 if (old_is_dir) 1031 f2fs_i_links_write(new_inode, false); 1032 f2fs_i_links_write(new_inode, false); 1033 f2fs_up_write(&F2FS_I(new_inode)->i_sem); 1034 1035 if (!new_inode->i_nlink) 1036 f2fs_add_orphan_inode(new_inode); 1037 else 1038 f2fs_release_orphan_inode(sbi); 1039 } else { 1040 f2fs_balance_fs(sbi, true); 1041 1042 f2fs_lock_op(sbi, &lc); 1043 1044 err = f2fs_add_link(new_dentry, old_inode); 1045 if (err) { 1046 f2fs_unlock_op(sbi, &lc); 1047 goto out_dir; 1048 } 1049 1050 if (old_is_dir) 1051 f2fs_i_links_write(new_dir, true); 1052 } 1053 1054 f2fs_down_write(&F2FS_I(old_inode)->i_sem); 1055 if (!old_is_dir || whiteout) 1056 file_lost_pino(old_inode); 1057 else 1058 /* adjust dir's i_pino to pass fsck check */ 1059 f2fs_i_pino_write(old_inode, new_dir->i_ino); 1060 f2fs_up_write(&F2FS_I(old_inode)->i_sem); 1061 1062 inode_set_ctime_current(old_inode); 1063 f2fs_mark_inode_dirty_sync(old_inode, false); 1064 1065 f2fs_delete_entry(old_entry, old_folio, old_dir, NULL); 1066 old_folio = NULL; 1067 1068 if (whiteout) { 1069 set_inode_flag(whiteout, FI_INC_LINK); 1070 err = f2fs_add_link(old_dentry, whiteout); 1071 if (err) { 1072 d_invalidate(old_dentry); 1073 d_invalidate(new_dentry); 1074 goto put_out_dir; 1075 } 1076 spin_lock(&whiteout->i_lock); 1077 inode_state_clear(whiteout, I_LINKABLE); 1078 spin_unlock(&whiteout->i_lock); 1079 1080 iput(whiteout); 1081 } 1082 1083 if (old_dir_entry) 1084 f2fs_set_link(old_inode, old_dir_entry, old_dir_folio, new_dir); 1085 if (old_is_dir) 1086 f2fs_i_links_write(old_dir, false); 1087 1088 if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT) { 1089 f2fs_add_ino_entry(sbi, new_dir->i_ino, TRANS_DIR_INO); 1090 if (S_ISDIR(old_inode->i_mode)) 1091 f2fs_add_ino_entry(sbi, old_inode->i_ino, 1092 TRANS_DIR_INO); 1093 } 1094 1095 f2fs_unlock_op(sbi, &lc); 1096 1097 if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) 1098 f2fs_sync_fs(sbi->sb, 1); 1099 1100 f2fs_update_time(sbi, REQ_TIME); 1101 return 0; 1102 1103 put_out_dir: 1104 f2fs_unlock_op(sbi, &lc); 1105 f2fs_folio_put(new_folio, false); 1106 out_dir: 1107 if (old_dir_entry) 1108 f2fs_folio_put(old_dir_folio, false); 1109 out_old: 1110 f2fs_folio_put(old_folio, false); 1111 out: 1112 iput(whiteout); 1113 return err; 1114 } 1115 1116 static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, 1117 struct inode *new_dir, struct dentry *new_dentry) 1118 { 1119 struct f2fs_sb_info *sbi = F2FS_I_SB(old_dir); 1120 struct inode *old_inode = d_inode(old_dentry); 1121 struct inode *new_inode = d_inode(new_dentry); 1122 struct folio *old_dir_folio, *new_dir_folio; 1123 struct folio *old_folio, *new_folio; 1124 struct f2fs_dir_entry *old_dir_entry = NULL, *new_dir_entry = NULL; 1125 struct f2fs_dir_entry *old_entry, *new_entry; 1126 struct f2fs_lock_context lc; 1127 int old_nlink = 0, new_nlink = 0; 1128 int err; 1129 1130 if (unlikely(f2fs_cp_error(sbi))) 1131 return -EIO; 1132 if (!f2fs_is_checkpoint_ready(sbi)) 1133 return -ENOSPC; 1134 1135 if ((is_inode_flag_set(new_dir, FI_PROJ_INHERIT) && 1136 !projid_eq(F2FS_I(new_dir)->i_projid, 1137 F2FS_I(old_inode)->i_projid)) || 1138 (is_inode_flag_set(old_dir, FI_PROJ_INHERIT) && 1139 !projid_eq(F2FS_I(old_dir)->i_projid, 1140 F2FS_I(new_inode)->i_projid))) 1141 return -EXDEV; 1142 1143 err = f2fs_dquot_initialize(old_dir); 1144 if (err) 1145 goto out; 1146 1147 err = f2fs_dquot_initialize(new_dir); 1148 if (err) 1149 goto out; 1150 1151 err = -ENOENT; 1152 old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_folio); 1153 if (!old_entry) { 1154 if (IS_ERR(old_folio)) 1155 err = PTR_ERR(old_folio); 1156 goto out; 1157 } 1158 1159 new_entry = f2fs_find_entry(new_dir, &new_dentry->d_name, &new_folio); 1160 if (!new_entry) { 1161 if (IS_ERR(new_folio)) 1162 err = PTR_ERR(new_folio); 1163 goto out_old; 1164 } 1165 1166 /* prepare for updating ".." directory entry info later */ 1167 if (old_dir != new_dir) { 1168 if (S_ISDIR(old_inode->i_mode)) { 1169 old_dir_entry = f2fs_parent_dir(old_inode, 1170 &old_dir_folio); 1171 if (!old_dir_entry) { 1172 if (IS_ERR(old_dir_folio)) 1173 err = PTR_ERR(old_dir_folio); 1174 goto out_new; 1175 } 1176 } 1177 1178 if (S_ISDIR(new_inode->i_mode)) { 1179 new_dir_entry = f2fs_parent_dir(new_inode, 1180 &new_dir_folio); 1181 if (!new_dir_entry) { 1182 if (IS_ERR(new_dir_folio)) 1183 err = PTR_ERR(new_dir_folio); 1184 goto out_old_dir; 1185 } 1186 } 1187 } 1188 1189 /* 1190 * If cross rename between file and directory those are not 1191 * in the same directory, we will inc nlink of file's parent 1192 * later, so we should check upper boundary of its nlink. 1193 */ 1194 if ((!old_dir_entry || !new_dir_entry) && 1195 old_dir_entry != new_dir_entry) { 1196 old_nlink = old_dir_entry ? -1 : 1; 1197 new_nlink = -old_nlink; 1198 err = -EMLINK; 1199 if ((old_nlink > 0 && old_dir->i_nlink >= F2FS_LINK_MAX) || 1200 (new_nlink > 0 && new_dir->i_nlink >= F2FS_LINK_MAX)) 1201 goto out_new_dir; 1202 } 1203 1204 f2fs_balance_fs(sbi, true); 1205 1206 f2fs_lock_op(sbi, &lc); 1207 1208 /* update ".." directory entry info of old dentry */ 1209 if (old_dir_entry) 1210 f2fs_set_link(old_inode, old_dir_entry, old_dir_folio, new_dir); 1211 1212 /* update ".." directory entry info of new dentry */ 1213 if (new_dir_entry) 1214 f2fs_set_link(new_inode, new_dir_entry, new_dir_folio, old_dir); 1215 1216 /* update directory entry info of old dir inode */ 1217 f2fs_set_link(old_dir, old_entry, old_folio, new_inode); 1218 1219 f2fs_down_write(&F2FS_I(old_inode)->i_sem); 1220 if (!old_dir_entry) 1221 file_lost_pino(old_inode); 1222 else 1223 /* adjust dir's i_pino to pass fsck check */ 1224 f2fs_i_pino_write(old_inode, new_dir->i_ino); 1225 f2fs_up_write(&F2FS_I(old_inode)->i_sem); 1226 1227 inode_set_ctime_current(old_dir); 1228 if (old_nlink) { 1229 f2fs_down_write(&F2FS_I(old_dir)->i_sem); 1230 f2fs_i_links_write(old_dir, old_nlink > 0); 1231 f2fs_up_write(&F2FS_I(old_dir)->i_sem); 1232 } 1233 f2fs_mark_inode_dirty_sync(old_dir, false); 1234 1235 /* update directory entry info of new dir inode */ 1236 f2fs_set_link(new_dir, new_entry, new_folio, old_inode); 1237 1238 f2fs_down_write(&F2FS_I(new_inode)->i_sem); 1239 if (!new_dir_entry) 1240 file_lost_pino(new_inode); 1241 else 1242 /* adjust dir's i_pino to pass fsck check */ 1243 f2fs_i_pino_write(new_inode, old_dir->i_ino); 1244 f2fs_up_write(&F2FS_I(new_inode)->i_sem); 1245 1246 inode_set_ctime_current(new_dir); 1247 if (new_nlink) { 1248 f2fs_down_write(&F2FS_I(new_dir)->i_sem); 1249 f2fs_i_links_write(new_dir, new_nlink > 0); 1250 f2fs_up_write(&F2FS_I(new_dir)->i_sem); 1251 } 1252 f2fs_mark_inode_dirty_sync(new_dir, false); 1253 1254 if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT) { 1255 f2fs_add_ino_entry(sbi, old_dir->i_ino, TRANS_DIR_INO); 1256 f2fs_add_ino_entry(sbi, new_dir->i_ino, TRANS_DIR_INO); 1257 } 1258 1259 f2fs_unlock_op(sbi, &lc); 1260 1261 if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) 1262 f2fs_sync_fs(sbi->sb, 1); 1263 1264 f2fs_update_time(sbi, REQ_TIME); 1265 return 0; 1266 out_new_dir: 1267 if (new_dir_entry) { 1268 f2fs_folio_put(new_dir_folio, false); 1269 } 1270 out_old_dir: 1271 if (old_dir_entry) { 1272 f2fs_folio_put(old_dir_folio, false); 1273 } 1274 out_new: 1275 f2fs_folio_put(new_folio, false); 1276 out_old: 1277 f2fs_folio_put(old_folio, false); 1278 out: 1279 return err; 1280 } 1281 1282 static int f2fs_rename2(struct mnt_idmap *idmap, 1283 struct inode *old_dir, struct dentry *old_dentry, 1284 struct inode *new_dir, struct dentry *new_dentry, 1285 unsigned int flags) 1286 { 1287 int err; 1288 1289 if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT)) 1290 return -EINVAL; 1291 1292 trace_f2fs_rename_start(old_dir, old_dentry, new_dir, new_dentry, 1293 flags); 1294 1295 err = fscrypt_prepare_rename(old_dir, old_dentry, new_dir, new_dentry, 1296 flags); 1297 if (err) 1298 return err; 1299 1300 if (flags & RENAME_EXCHANGE) 1301 err = f2fs_cross_rename(old_dir, old_dentry, 1302 new_dir, new_dentry); 1303 else 1304 /* 1305 * VFS has already handled the new dentry existence case, 1306 * here, we just deal with "RENAME_NOREPLACE" as regular rename. 1307 */ 1308 err = f2fs_rename(idmap, old_dir, old_dentry, 1309 new_dir, new_dentry, flags); 1310 1311 trace_f2fs_rename_end(old_dentry, new_dentry, flags, err); 1312 return err; 1313 } 1314 1315 static const char *f2fs_encrypted_get_link(struct dentry *dentry, 1316 struct inode *inode, 1317 struct delayed_call *done) 1318 { 1319 struct folio *folio; 1320 const char *target; 1321 1322 if (!dentry) 1323 return ERR_PTR(-ECHILD); 1324 1325 folio = read_mapping_folio(inode->i_mapping, 0, NULL); 1326 if (IS_ERR(folio)) 1327 return ERR_CAST(folio); 1328 1329 target = fscrypt_get_symlink(inode, folio_address(folio), 1330 inode->i_sb->s_blocksize, done); 1331 folio_put(folio); 1332 return target; 1333 } 1334 1335 static int f2fs_encrypted_symlink_getattr(struct mnt_idmap *idmap, 1336 const struct path *path, 1337 struct kstat *stat, u32 request_mask, 1338 unsigned int query_flags) 1339 { 1340 f2fs_getattr(idmap, path, stat, request_mask, query_flags); 1341 1342 return fscrypt_symlink_getattr(path, stat); 1343 } 1344 1345 const struct inode_operations f2fs_encrypted_symlink_inode_operations = { 1346 .get_link = f2fs_encrypted_get_link, 1347 .getattr = f2fs_encrypted_symlink_getattr, 1348 .setattr = f2fs_setattr, 1349 .listxattr = f2fs_listxattr, 1350 }; 1351 1352 const struct inode_operations f2fs_dir_inode_operations = { 1353 .create = f2fs_create, 1354 .lookup = f2fs_lookup, 1355 .link = f2fs_link, 1356 .unlink = f2fs_unlink, 1357 .symlink = f2fs_symlink, 1358 .mkdir = f2fs_mkdir, 1359 .rmdir = f2fs_rmdir, 1360 .mknod = f2fs_mknod, 1361 .rename = f2fs_rename2, 1362 .tmpfile = f2fs_tmpfile, 1363 .getattr = f2fs_getattr, 1364 .setattr = f2fs_setattr, 1365 .get_inode_acl = f2fs_get_acl, 1366 .set_acl = f2fs_set_acl, 1367 .listxattr = f2fs_listxattr, 1368 .fiemap = f2fs_fiemap, 1369 .fileattr_get = f2fs_fileattr_get, 1370 .fileattr_set = f2fs_fileattr_set, 1371 }; 1372 1373 const struct inode_operations f2fs_symlink_inode_operations = { 1374 .get_link = f2fs_get_link, 1375 .getattr = f2fs_getattr, 1376 .setattr = f2fs_setattr, 1377 .listxattr = f2fs_listxattr, 1378 }; 1379 1380 const struct inode_operations f2fs_special_inode_operations = { 1381 .getattr = f2fs_getattr, 1382 .setattr = f2fs_setattr, 1383 .get_inode_acl = f2fs_get_acl, 1384 .set_acl = f2fs_set_acl, 1385 .listxattr = f2fs_listxattr, 1386 }; 1387