namei.c (b97a9b5da891ab6aff5a6a19c569c9c4c5563d48) | namei.c (a014e037be26b5c9ee6fb4e49e7804141cf3bb89) |
---|---|
1/* 2 * fs/f2fs/namei.c 3 * 4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 5 * http://www.samsung.com/ 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 9 unchanged lines hidden (view full) --- 18#include "f2fs.h" 19#include "node.h" 20#include "xattr.h" 21#include "acl.h" 22#include <trace/events/f2fs.h> 23 24static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) 25{ | 1/* 2 * fs/f2fs/namei.c 3 * 4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 5 * http://www.samsung.com/ 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 9 unchanged lines hidden (view full) --- 18#include "f2fs.h" 19#include "node.h" 20#include "xattr.h" 21#include "acl.h" 22#include <trace/events/f2fs.h> 23 24static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) 25{ |
26 struct super_block *sb = dir->i_sb; 27 struct f2fs_sb_info *sbi = F2FS_SB(sb); | 26 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); |
28 nid_t ino; 29 struct inode *inode; 30 bool nid_free = false; 31 int err; 32 | 27 nid_t ino; 28 struct inode *inode; 29 bool nid_free = false; 30 int err; 31 |
33 inode = new_inode(sb); | 32 inode = new_inode(dir->i_sb); |
34 if (!inode) 35 return ERR_PTR(-ENOMEM); 36 37 f2fs_lock_op(sbi); 38 if (!alloc_nid(sbi, &ino)) { 39 f2fs_unlock_op(sbi); 40 err = -ENOSPC; 41 goto fail; --- 56 unchanged lines hidden (view full) --- 98 break; 99 } 100 } 101} 102 103static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, 104 bool excl) 105{ | 33 if (!inode) 34 return ERR_PTR(-ENOMEM); 35 36 f2fs_lock_op(sbi); 37 if (!alloc_nid(sbi, &ino)) { 38 f2fs_unlock_op(sbi); 39 err = -ENOSPC; 40 goto fail; --- 56 unchanged lines hidden (view full) --- 97 break; 98 } 99 } 100} 101 102static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, 103 bool excl) 104{ |
106 struct super_block *sb = dir->i_sb; 107 struct f2fs_sb_info *sbi = F2FS_SB(sb); | 105 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); |
108 struct inode *inode; 109 nid_t ino = 0; 110 int err; 111 112 f2fs_balance_fs(sbi); 113 114 inode = f2fs_new_inode(dir, mode); 115 if (IS_ERR(inode)) --- 26 unchanged lines hidden (view full) --- 142 alloc_nid_failed(sbi, ino); 143 return err; 144} 145 146static int f2fs_link(struct dentry *old_dentry, struct inode *dir, 147 struct dentry *dentry) 148{ 149 struct inode *inode = old_dentry->d_inode; | 106 struct inode *inode; 107 nid_t ino = 0; 108 int err; 109 110 f2fs_balance_fs(sbi); 111 112 inode = f2fs_new_inode(dir, mode); 113 if (IS_ERR(inode)) --- 26 unchanged lines hidden (view full) --- 140 alloc_nid_failed(sbi, ino); 141 return err; 142} 143 144static int f2fs_link(struct dentry *old_dentry, struct inode *dir, 145 struct dentry *dentry) 146{ 147 struct inode *inode = old_dentry->d_inode; |
150 struct super_block *sb = dir->i_sb; 151 struct f2fs_sb_info *sbi = F2FS_SB(sb); | 148 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); |
152 int err; 153 154 f2fs_balance_fs(sbi); 155 156 inode->i_ctime = CURRENT_TIME; 157 ihold(inode); 158 159 set_inode_flag(F2FS_I(inode), FI_INC_LINK); --- 43 unchanged lines hidden (view full) --- 203 stat_inc_inline_inode(inode); 204 } 205 206 return d_splice_alias(inode, dentry); 207} 208 209static int f2fs_unlink(struct inode *dir, struct dentry *dentry) 210{ | 149 int err; 150 151 f2fs_balance_fs(sbi); 152 153 inode->i_ctime = CURRENT_TIME; 154 ihold(inode); 155 156 set_inode_flag(F2FS_I(inode), FI_INC_LINK); --- 43 unchanged lines hidden (view full) --- 200 stat_inc_inline_inode(inode); 201 } 202 203 return d_splice_alias(inode, dentry); 204} 205 206static int f2fs_unlink(struct inode *dir, struct dentry *dentry) 207{ |
211 struct super_block *sb = dir->i_sb; 212 struct f2fs_sb_info *sbi = F2FS_SB(sb); | 208 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); |
213 struct inode *inode = dentry->d_inode; 214 struct f2fs_dir_entry *de; 215 struct page *page; 216 int err = -ENOENT; 217 218 trace_f2fs_unlink_enter(dir, dentry); 219 f2fs_balance_fs(sbi); 220 --- 17 unchanged lines hidden (view full) --- 238fail: 239 trace_f2fs_unlink_exit(inode, err); 240 return err; 241} 242 243static int f2fs_symlink(struct inode *dir, struct dentry *dentry, 244 const char *symname) 245{ | 209 struct inode *inode = dentry->d_inode; 210 struct f2fs_dir_entry *de; 211 struct page *page; 212 int err = -ENOENT; 213 214 trace_f2fs_unlink_enter(dir, dentry); 215 f2fs_balance_fs(sbi); 216 --- 17 unchanged lines hidden (view full) --- 234fail: 235 trace_f2fs_unlink_exit(inode, err); 236 return err; 237} 238 239static int f2fs_symlink(struct inode *dir, struct dentry *dentry, 240 const char *symname) 241{ |
246 struct super_block *sb = dir->i_sb; 247 struct f2fs_sb_info *sbi = F2FS_SB(sb); | 242 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); |
248 struct inode *inode; 249 size_t symlen = strlen(symname) + 1; 250 int err; 251 252 f2fs_balance_fs(sbi); 253 254 inode = f2fs_new_inode(dir, S_IFLNK | S_IRWXUGO); 255 if (IS_ERR(inode)) --- 70 unchanged lines hidden (view full) --- 326 if (f2fs_empty_dir(inode)) 327 return f2fs_unlink(dir, dentry); 328 return -ENOTEMPTY; 329} 330 331static int f2fs_mknod(struct inode *dir, struct dentry *dentry, 332 umode_t mode, dev_t rdev) 333{ | 243 struct inode *inode; 244 size_t symlen = strlen(symname) + 1; 245 int err; 246 247 f2fs_balance_fs(sbi); 248 249 inode = f2fs_new_inode(dir, S_IFLNK | S_IRWXUGO); 250 if (IS_ERR(inode)) --- 70 unchanged lines hidden (view full) --- 321 if (f2fs_empty_dir(inode)) 322 return f2fs_unlink(dir, dentry); 323 return -ENOTEMPTY; 324} 325 326static int f2fs_mknod(struct inode *dir, struct dentry *dentry, 327 umode_t mode, dev_t rdev) 328{ |
334 struct super_block *sb = dir->i_sb; 335 struct f2fs_sb_info *sbi = F2FS_SB(sb); | 329 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); |
336 struct inode *inode; 337 int err = 0; 338 339 if (!new_valid_dev(rdev)) 340 return -EINVAL; 341 342 f2fs_balance_fs(sbi); 343 --- 21 unchanged lines hidden (view full) --- 365 iput(inode); 366 alloc_nid_failed(sbi, inode->i_ino); 367 return err; 368} 369 370static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, 371 struct inode *new_dir, struct dentry *new_dentry) 372{ | 330 struct inode *inode; 331 int err = 0; 332 333 if (!new_valid_dev(rdev)) 334 return -EINVAL; 335 336 f2fs_balance_fs(sbi); 337 --- 21 unchanged lines hidden (view full) --- 359 iput(inode); 360 alloc_nid_failed(sbi, inode->i_ino); 361 return err; 362} 363 364static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, 365 struct inode *new_dir, struct dentry *new_dentry) 366{ |
373 struct super_block *sb = old_dir->i_sb; 374 struct f2fs_sb_info *sbi = F2FS_SB(sb); | 367 struct f2fs_sb_info *sbi = F2FS_SB(old_dir->i_sb); |
375 struct inode *old_inode = old_dentry->d_inode; 376 struct inode *new_inode = new_dentry->d_inode; 377 struct page *old_dir_page; 378 struct page *old_page, *new_page; 379 struct f2fs_dir_entry *old_dir_entry = NULL; 380 struct f2fs_dir_entry *old_entry; 381 struct f2fs_dir_entry *new_entry; 382 int err = -ENOENT; --- 102 unchanged lines hidden (view full) --- 485 kunmap(old_page); 486 f2fs_put_page(old_page, 0); 487out: 488 return err; 489} 490 491static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) 492{ | 368 struct inode *old_inode = old_dentry->d_inode; 369 struct inode *new_inode = new_dentry->d_inode; 370 struct page *old_dir_page; 371 struct page *old_page, *new_page; 372 struct f2fs_dir_entry *old_dir_entry = NULL; 373 struct f2fs_dir_entry *old_entry; 374 struct f2fs_dir_entry *new_entry; 375 int err = -ENOENT; --- 102 unchanged lines hidden (view full) --- 478 kunmap(old_page); 479 f2fs_put_page(old_page, 0); 480out: 481 return err; 482} 483 484static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) 485{ |
493 struct super_block *sb = dir->i_sb; 494 struct f2fs_sb_info *sbi = F2FS_SB(sb); | 486 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); |
495 struct inode *inode; 496 int err; 497 498 inode = f2fs_new_inode(dir, mode); 499 if (IS_ERR(inode)) 500 return PTR_ERR(inode); 501 502 inode->i_op = &f2fs_file_inode_operations; --- 85 unchanged lines hidden --- | 487 struct inode *inode; 488 int err; 489 490 inode = f2fs_new_inode(dir, mode); 491 if (IS_ERR(inode)) 492 return PTR_ERR(inode); 493 494 inode->i_op = &f2fs_file_inode_operations; --- 85 unchanged lines hidden --- |