blob: 2076225787d1dfa00f5f5b33c24277c78a8540bb [file] [log] [blame]
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +09001/*
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +09002 * fs/f2fs/inode.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 * published by the Free Software Foundation.
10 */
11#include <linux/fs.h>
12#include <linux/f2fs_fs.h>
13#include <linux/buffer_head.h>
Jaegeuk Kime8ea9b32016-09-09 16:59:39 -070014#include <linux/backing-dev.h>
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +090015#include <linux/writeback.h>
16
17#include "f2fs.h"
18#include "node.h"
Chao Yu0eb0ada2017-06-14 23:00:56 +080019#include "segment.h"
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +090020
Namjae Jeona2a4a7e2013-04-20 01:28:40 +090021#include <trace/events/f2fs.h>
22
Jaegeuk Kim7c457292016-10-14 11:51:23 -070023void f2fs_mark_inode_dirty_sync(struct inode *inode, bool sync)
Jaegeuk Kimb56ab832016-06-30 19:09:37 -070024{
Daeho Jeong9ac1e2d2018-01-11 11:26:19 +090025 if (is_inode_flag_set(inode, FI_NEW_INODE))
26 return;
27
Jaegeuk Kim7c457292016-10-14 11:51:23 -070028 if (f2fs_inode_dirtied(inode, sync))
Jaegeuk Kimb56ab832016-06-30 19:09:37 -070029 return;
Jaegeuk Kim7c457292016-10-14 11:51:23 -070030
Jaegeuk Kimb56ab832016-06-30 19:09:37 -070031 mark_inode_dirty_sync(inode);
32}
33
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +090034void f2fs_set_inode_flags(struct inode *inode)
35{
36 unsigned int flags = F2FS_I(inode)->i_flags;
Zhang Zhen8abfb362014-04-15 14:19:38 +080037 unsigned int new_fl = 0;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +090038
Chao Yu59c84402018-04-03 15:08:17 +080039 if (flags & F2FS_SYNC_FL)
Zhang Zhen8abfb362014-04-15 14:19:38 +080040 new_fl |= S_SYNC;
Chao Yu59c84402018-04-03 15:08:17 +080041 if (flags & F2FS_APPEND_FL)
Zhang Zhen8abfb362014-04-15 14:19:38 +080042 new_fl |= S_APPEND;
Chao Yu59c84402018-04-03 15:08:17 +080043 if (flags & F2FS_IMMUTABLE_FL)
Zhang Zhen8abfb362014-04-15 14:19:38 +080044 new_fl |= S_IMMUTABLE;
Chao Yu59c84402018-04-03 15:08:17 +080045 if (flags & F2FS_NOATIME_FL)
Zhang Zhen8abfb362014-04-15 14:19:38 +080046 new_fl |= S_NOATIME;
Chao Yu59c84402018-04-03 15:08:17 +080047 if (flags & F2FS_DIRSYNC_FL)
Zhang Zhen8abfb362014-04-15 14:19:38 +080048 new_fl |= S_DIRSYNC;
Eric Biggers2ee6a572017-10-09 12:15:35 -070049 if (f2fs_encrypted_inode(inode))
50 new_fl |= S_ENCRYPTED;
Zhang Zhen6a678852015-08-24 10:41:32 +080051 inode_set_flags(inode, new_fl,
Eric Biggers2ee6a572017-10-09 12:15:35 -070052 S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|
53 S_ENCRYPTED);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +090054}
55
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +090056static void __get_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
57{
Chao Yu7a2af762017-07-19 00:19:06 +080058 int extra_size = get_extra_isize(inode);
59
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +090060 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
61 S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
Chao Yu7a2af762017-07-19 00:19:06 +080062 if (ri->i_addr[extra_size])
63 inode->i_rdev = old_decode_dev(
64 le32_to_cpu(ri->i_addr[extra_size]));
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +090065 else
Chao Yu7a2af762017-07-19 00:19:06 +080066 inode->i_rdev = new_decode_dev(
67 le32_to_cpu(ri->i_addr[extra_size + 1]));
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +090068 }
69}
70
Jaegeuk Kim3c6c2be2015-03-17 17:16:35 -070071static bool __written_first_block(struct f2fs_inode *ri)
72{
Chao Yu7a2af762017-07-19 00:19:06 +080073 block_t addr = le32_to_cpu(ri->i_addr[offset_in_addr(ri)]);
Jaegeuk Kimadad81e2015-03-24 12:04:20 -070074
Chao Yu7b525dd2018-05-23 22:25:08 +080075 if (is_valid_blkaddr(addr))
Jaegeuk Kim3c6c2be2015-03-17 17:16:35 -070076 return true;
77 return false;
78}
79
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +090080static void __set_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
81{
Chao Yu7a2af762017-07-19 00:19:06 +080082 int extra_size = get_extra_isize(inode);
83
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +090084 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
85 if (old_valid_dev(inode->i_rdev)) {
Chao Yu7a2af762017-07-19 00:19:06 +080086 ri->i_addr[extra_size] =
Chris Fries6c311ec2014-01-17 14:44:39 -060087 cpu_to_le32(old_encode_dev(inode->i_rdev));
Chao Yu7a2af762017-07-19 00:19:06 +080088 ri->i_addr[extra_size + 1] = 0;
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +090089 } else {
Chao Yu7a2af762017-07-19 00:19:06 +080090 ri->i_addr[extra_size] = 0;
91 ri->i_addr[extra_size + 1] =
Chris Fries6c311ec2014-01-17 14:44:39 -060092 cpu_to_le32(new_encode_dev(inode->i_rdev));
Chao Yu7a2af762017-07-19 00:19:06 +080093 ri->i_addr[extra_size + 2] = 0;
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +090094 }
95 }
96}
97
Chao Yu9e5ba772015-01-06 14:28:43 +080098static void __recover_inline_status(struct inode *inode, struct page *ipage)
Jaegeuk Kimb3d208f2014-10-23 19:48:09 -070099{
Chao Yuf2470372017-07-19 00:19:05 +0800100 void *inline_data = inline_data_addr(inode, ipage);
Chao Yu9e5ba772015-01-06 14:28:43 +0800101 __le32 *start = inline_data;
Chao Yuf2470372017-07-19 00:19:05 +0800102 __le32 *end = start + MAX_INLINE_DATA(inode) / sizeof(__le32);
Jaegeuk Kimb3d208f2014-10-23 19:48:09 -0700103
Chao Yu9e5ba772015-01-06 14:28:43 +0800104 while (start < end) {
105 if (*start++) {
Jaegeuk Kimfec1d652016-01-20 23:43:51 +0800106 f2fs_wait_on_page_writeback(ipage, NODE, true);
Jaegeuk Kimb3d208f2014-10-23 19:48:09 -0700107
Jaegeuk Kim91942322016-05-20 10:13:22 -0700108 set_inode_flag(inode, FI_DATA_EXIST);
109 set_raw_inline(inode, F2FS_INODE(ipage));
Chao Yu9e5ba772015-01-06 14:28:43 +0800110 set_page_dirty(ipage);
111 return;
112 }
Jaegeuk Kimb3d208f2014-10-23 19:48:09 -0700113 }
Chao Yu9e5ba772015-01-06 14:28:43 +0800114 return;
Jaegeuk Kimb3d208f2014-10-23 19:48:09 -0700115}
116
Chao Yu704956e2017-07-31 20:19:09 +0800117static bool f2fs_enable_inode_chksum(struct f2fs_sb_info *sbi, struct page *page)
118{
119 struct f2fs_inode *ri = &F2FS_NODE(page)->i;
Chao Yu704956e2017-07-31 20:19:09 +0800120
121 if (!f2fs_sb_has_inode_chksum(sbi->sb))
122 return false;
123
124 if (!RAW_IS_INODE(F2FS_NODE(page)) || !(ri->i_inline & F2FS_EXTRA_ATTR))
125 return false;
126
Zhikang Zhangd6964942018-04-14 01:02:34 +0800127 if (!F2FS_FITS_IN_INODE(ri, le16_to_cpu(ri->i_extra_isize),
128 i_inode_checksum))
Chao Yu704956e2017-07-31 20:19:09 +0800129 return false;
130
131 return true;
132}
133
134static __u32 f2fs_inode_chksum(struct f2fs_sb_info *sbi, struct page *page)
135{
136 struct f2fs_node *node = F2FS_NODE(page);
137 struct f2fs_inode *ri = &node->i;
138 __le32 ino = node->footer.ino;
139 __le32 gen = ri->i_generation;
140 __u32 chksum, chksum_seed;
141 __u32 dummy_cs = 0;
142 unsigned int offset = offsetof(struct f2fs_inode, i_inode_checksum);
143 unsigned int cs_size = sizeof(dummy_cs);
144
145 chksum = f2fs_chksum(sbi, sbi->s_chksum_seed, (__u8 *)&ino,
146 sizeof(ino));
147 chksum_seed = f2fs_chksum(sbi, chksum, (__u8 *)&gen, sizeof(gen));
148
149 chksum = f2fs_chksum(sbi, chksum_seed, (__u8 *)ri, offset);
150 chksum = f2fs_chksum(sbi, chksum, (__u8 *)&dummy_cs, cs_size);
151 offset += cs_size;
152 chksum = f2fs_chksum(sbi, chksum, (__u8 *)ri + offset,
153 F2FS_BLKSIZE - offset);
154 return chksum;
155}
156
157bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page)
158{
159 struct f2fs_inode *ri;
160 __u32 provided, calculated;
161
Jaegeuk Kim83a3bfd2018-06-21 13:46:23 -0700162 if (unlikely(is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN)))
163 return true;
164
Weichao Guo54c55c42018-03-09 23:10:21 +0800165#ifdef CONFIG_F2FS_CHECK_FS
166 if (!f2fs_enable_inode_chksum(sbi, page))
167#else
Jaegeuk Kimee605232017-08-31 16:54:51 -0700168 if (!f2fs_enable_inode_chksum(sbi, page) ||
169 PageDirty(page) || PageWriteback(page))
Weichao Guo54c55c42018-03-09 23:10:21 +0800170#endif
Chao Yu704956e2017-07-31 20:19:09 +0800171 return true;
172
173 ri = &F2FS_NODE(page)->i;
174 provided = le32_to_cpu(ri->i_inode_checksum);
175 calculated = f2fs_inode_chksum(sbi, page);
176
177 if (provided != calculated)
178 f2fs_msg(sbi->sb, KERN_WARNING,
179 "checksum invalid, ino = %x, %x vs. %x",
180 ino_of_node(page), provided, calculated);
181
182 return provided == calculated;
183}
184
185void f2fs_inode_chksum_set(struct f2fs_sb_info *sbi, struct page *page)
186{
187 struct f2fs_inode *ri = &F2FS_NODE(page)->i;
188
189 if (!f2fs_enable_inode_chksum(sbi, page))
190 return;
191
192 ri->i_inode_checksum = cpu_to_le32(f2fs_inode_chksum(sbi, page));
193}
194
Jaegeuk Kim5d646002018-04-24 11:37:18 -0600195static bool sanity_check_inode(struct inode *inode)
196{
197 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
198
199 if (f2fs_sb_has_flexible_inline_xattr(sbi->sb)
200 && !f2fs_has_extra_attr(inode)) {
201 set_sbi_flag(sbi, SBI_NEED_FSCK);
202 f2fs_msg(sbi->sb, KERN_WARNING,
203 "%s: corrupted inode ino=%lx, run fsck to fix.",
204 __func__, inode->i_ino);
205 return false;
206 }
207 return true;
208}
209
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900210static int do_read_inode(struct inode *inode)
211{
Jaegeuk Kim40813632014-09-02 15:31:18 -0700212 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900213 struct f2fs_inode_info *fi = F2FS_I(inode);
214 struct page *node_page;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900215 struct f2fs_inode *ri;
Chao Yu5c571322017-07-26 00:01:41 +0800216 projid_t i_projid;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900217
218 /* Check if ino is within scope */
Chao Yu4d57b862018-05-30 00:20:41 +0800219 if (f2fs_check_nid_range(sbi, inode->i_ino))
Namjae Jeon064e0822013-03-17 17:27:20 +0900220 return -EINVAL;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900221
Chao Yu4d57b862018-05-30 00:20:41 +0800222 node_page = f2fs_get_node_page(sbi, inode->i_ino);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900223 if (IS_ERR(node_page))
224 return PTR_ERR(node_page);
225
Jaegeuk Kim58bfaf42013-12-26 16:30:41 +0900226 ri = F2FS_INODE(node_page);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900227
228 inode->i_mode = le16_to_cpu(ri->i_mode);
229 i_uid_write(inode, le32_to_cpu(ri->i_uid));
230 i_gid_write(inode, le32_to_cpu(ri->i_gid));
231 set_nlink(inode, le32_to_cpu(ri->i_links));
232 inode->i_size = le64_to_cpu(ri->i_size);
Chao Yu000519f2017-07-06 01:11:31 +0800233 inode->i_blocks = SECTOR_FROM_BLOCK(le64_to_cpu(ri->i_blocks) - 1);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900234
235 inode->i_atime.tv_sec = le64_to_cpu(ri->i_atime);
236 inode->i_ctime.tv_sec = le64_to_cpu(ri->i_ctime);
237 inode->i_mtime.tv_sec = le64_to_cpu(ri->i_mtime);
238 inode->i_atime.tv_nsec = le32_to_cpu(ri->i_atime_nsec);
239 inode->i_ctime.tv_nsec = le32_to_cpu(ri->i_ctime_nsec);
240 inode->i_mtime.tv_nsec = le32_to_cpu(ri->i_mtime_nsec);
241 inode->i_generation = le32_to_cpu(ri->i_generation);
Chao Yu1c41e6802018-05-07 20:28:52 +0800242 if (S_ISDIR(inode->i_mode))
243 fi->i_current_depth = le32_to_cpu(ri->i_current_depth);
244 else if (S_ISREG(inode->i_mode))
Chao Yu2ef79ec2018-05-07 20:28:54 +0800245 fi->i_gc_failures[GC_FAILURE_PIN] =
246 le16_to_cpu(ri->i_gc_failures);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900247 fi->i_xattr_nid = le32_to_cpu(ri->i_xattr_nid);
248 fi->i_flags = le32_to_cpu(ri->i_flags);
249 fi->flags = 0;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900250 fi->i_advise = ri->i_advise;
Jaegeuk Kim6666e6a2012-12-10 17:52:48 +0900251 fi->i_pino = le32_to_cpu(ri->i_pino);
Jaegeuk Kim38431542014-02-27 18:20:00 +0900252 fi->i_dir_level = ri->i_dir_level;
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +0900253
Jaegeuk Kimed3d1252015-12-28 11:39:06 -0800254 if (f2fs_init_extent_tree(inode, &ri->i_ext))
255 set_page_dirty(node_page);
Chao Yu0c872e22015-02-05 17:46:29 +0800256
Jaegeuk Kim91942322016-05-20 10:13:22 -0700257 get_inline_info(inode, ri);
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +0900258
Chao Yu7a2af762017-07-19 00:19:06 +0800259 fi->i_extra_isize = f2fs_has_extra_attr(inode) ?
260 le16_to_cpu(ri->i_extra_isize) : 0;
261
Chao Yu6afc6622017-09-06 21:59:50 +0800262 if (f2fs_sb_has_flexible_inline_xattr(sbi->sb)) {
Chao Yu6afc6622017-09-06 21:59:50 +0800263 fi->i_inline_xattr_size = le16_to_cpu(ri->i_inline_xattr_size);
264 } else if (f2fs_has_inline_xattr(inode) ||
265 f2fs_has_inline_dentry(inode)) {
266 fi->i_inline_xattr_size = DEFAULT_INLINE_XATTR_ADDRS;
267 } else {
268
269 /*
270 * Previous inline data or directory always reserved 200 bytes
271 * in inode layout, even if inline_xattr is disabled. In order
272 * to keep inline_dentry's structure for backward compatibility,
273 * we get the space back only from inline_data.
274 */
275 fi->i_inline_xattr_size = 0;
276 }
277
Jaegeuk Kimb3d208f2014-10-23 19:48:09 -0700278 /* check data exist */
279 if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode))
Chao Yu9e5ba772015-01-06 14:28:43 +0800280 __recover_inline_status(inode, node_page);
Jaegeuk Kimb3d208f2014-10-23 19:48:09 -0700281
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +0900282 /* get rdev by using inline_info */
283 __get_inode_rdev(inode, ri);
284
Jaegeuk Kim3c6c2be2015-03-17 17:16:35 -0700285 if (__written_first_block(ri))
Jaegeuk Kim91942322016-05-20 10:13:22 -0700286 set_inode_flag(inode, FI_FIRST_BLOCK_WRITTEN);
Jaegeuk Kim3c6c2be2015-03-17 17:16:35 -0700287
Chao Yu4d57b862018-05-30 00:20:41 +0800288 if (!f2fs_need_inode_block_update(sbi, inode->i_ino))
Jaegeuk Kim26de9b12016-05-20 20:42:37 -0700289 fi->last_disk_size = inode->i_size;
290
Chao Yu59c84402018-04-03 15:08:17 +0800291 if (fi->i_flags & F2FS_PROJINHERIT_FL)
Chao Yu5c571322017-07-26 00:01:41 +0800292 set_inode_flag(inode, FI_PROJ_INHERIT);
293
294 if (f2fs_has_extra_attr(inode) && f2fs_sb_has_project_quota(sbi->sb) &&
295 F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_projid))
296 i_projid = (projid_t)le32_to_cpu(ri->i_projid);
297 else
298 i_projid = F2FS_DEF_PROJID;
299 fi->i_projid = make_kprojid(&init_user_ns, i_projid);
300
Chao Yu1c1d35d2018-01-25 14:54:42 +0800301 if (f2fs_has_extra_attr(inode) && f2fs_sb_has_inode_crtime(sbi->sb) &&
302 F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) {
303 fi->i_crtime.tv_sec = le64_to_cpu(ri->i_crtime);
304 fi->i_crtime.tv_nsec = le32_to_cpu(ri->i_crtime_nsec);
305 }
306
Arnd Bergmann24b81df2018-06-20 10:02:19 +0200307 F2FS_I(inode)->i_disk_time[0] = inode->i_atime;
308 F2FS_I(inode)->i_disk_time[1] = inode->i_ctime;
309 F2FS_I(inode)->i_disk_time[2] = inode->i_mtime;
Jaegeuk Kim214c2462018-03-29 22:50:41 -0700310 F2FS_I(inode)->i_disk_time[3] = F2FS_I(inode)->i_crtime;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900311 f2fs_put_page(node_page, 1);
Jaegeuk Kim9d1015d2014-12-05 10:51:50 -0800312
Chao Yud5e8f6c2015-07-15 17:28:53 +0800313 stat_inc_inline_xattr(inode);
Jaegeuk Kim9d1015d2014-12-05 10:51:50 -0800314 stat_inc_inline_inode(inode);
315 stat_inc_inline_dir(inode);
316
Chao Yu9e5ba772015-01-06 14:28:43 +0800317 return 0;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900318}
319
320struct inode *f2fs_iget(struct super_block *sb, unsigned long ino)
321{
322 struct f2fs_sb_info *sbi = F2FS_SB(sb);
323 struct inode *inode;
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900324 int ret = 0;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900325
326 inode = iget_locked(sb, ino);
327 if (!inode)
328 return ERR_PTR(-ENOMEM);
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900329
330 if (!(inode->i_state & I_NEW)) {
331 trace_f2fs_iget(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900332 return inode;
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900333 }
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900334 if (ino == F2FS_NODE_INO(sbi) || ino == F2FS_META_INO(sbi))
335 goto make_now;
336
337 ret = do_read_inode(inode);
338 if (ret)
339 goto bad_inode;
Jaegeuk Kim5d646002018-04-24 11:37:18 -0600340 if (!sanity_check_inode(inode)) {
341 ret = -EINVAL;
342 goto bad_inode;
343 }
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900344make_now:
345 if (ino == F2FS_NODE_INO(sbi)) {
346 inode->i_mapping->a_ops = &f2fs_node_aops;
Chao Yu81114ba2018-04-09 20:25:06 +0800347 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900348 } else if (ino == F2FS_META_INO(sbi)) {
349 inode->i_mapping->a_ops = &f2fs_meta_aops;
Chao Yu81114ba2018-04-09 20:25:06 +0800350 mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900351 } else if (S_ISREG(inode->i_mode)) {
352 inode->i_op = &f2fs_file_inode_operations;
353 inode->i_fop = &f2fs_file_operations;
354 inode->i_mapping->a_ops = &f2fs_dblock_aops;
355 } else if (S_ISDIR(inode->i_mode)) {
356 inode->i_op = &f2fs_dir_inode_operations;
357 inode->i_fop = &f2fs_dir_operations;
358 inode->i_mapping->a_ops = &f2fs_dblock_aops;
Yunlong Songbdbc90f2018-02-28 20:31:52 +0800359 inode_nohighmem(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900360 } else if (S_ISLNK(inode->i_mode)) {
Jaegeuk Kimcbaf0422015-04-29 15:10:53 -0700361 if (f2fs_encrypted_inode(inode))
362 inode->i_op = &f2fs_encrypted_symlink_inode_operations;
363 else
364 inode->i_op = &f2fs_symlink_inode_operations;
Al Viro21fc61c2015-11-17 01:07:57 -0500365 inode_nohighmem(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900366 inode->i_mapping->a_ops = &f2fs_dblock_aops;
367 } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
368 S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
369 inode->i_op = &f2fs_special_inode_operations;
370 init_special_inode(inode, inode->i_mode, inode->i_rdev);
371 } else {
372 ret = -EIO;
373 goto bad_inode;
374 }
Jaegeuk Kim93607122017-05-16 13:20:16 -0700375 f2fs_set_inode_flags(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900376 unlock_new_inode(inode);
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900377 trace_f2fs_iget(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900378 return inode;
379
380bad_inode:
381 iget_failed(inode);
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900382 trace_f2fs_iget_exit(inode, ret);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900383 return ERR_PTR(ret);
384}
385
Jaegeuk Kime8ea9b32016-09-09 16:59:39 -0700386struct inode *f2fs_iget_retry(struct super_block *sb, unsigned long ino)
387{
388 struct inode *inode;
389retry:
390 inode = f2fs_iget(sb, ino);
391 if (IS_ERR(inode)) {
392 if (PTR_ERR(inode) == -ENOMEM) {
393 congestion_wait(BLK_RW_ASYNC, HZ/50);
394 goto retry;
395 }
396 }
397 return inode;
398}
399
Chao Yu4d57b862018-05-30 00:20:41 +0800400void f2fs_update_inode(struct inode *inode, struct page *node_page)
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900401{
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900402 struct f2fs_inode *ri;
Chao Yub691d982016-10-11 22:57:05 +0800403 struct extent_tree *et = F2FS_I(inode)->extent_tree;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900404
Jaegeuk Kimfec1d652016-01-20 23:43:51 +0800405 f2fs_wait_on_page_writeback(node_page, NODE, true);
Yunlei He211a6fa2017-12-05 12:07:47 +0800406 set_page_dirty(node_page);
407
408 f2fs_inode_synced(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900409
Jaegeuk Kim58bfaf42013-12-26 16:30:41 +0900410 ri = F2FS_INODE(node_page);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900411
412 ri->i_mode = cpu_to_le16(inode->i_mode);
413 ri->i_advise = F2FS_I(inode)->i_advise;
414 ri->i_uid = cpu_to_le32(i_uid_read(inode));
415 ri->i_gid = cpu_to_le32(i_gid_read(inode));
416 ri->i_links = cpu_to_le32(inode->i_nlink);
417 ri->i_size = cpu_to_le64(i_size_read(inode));
Chao Yu000519f2017-07-06 01:11:31 +0800418 ri->i_blocks = cpu_to_le64(SECTOR_TO_BLOCK(inode->i_blocks) + 1);
Chao Yu0c872e22015-02-05 17:46:29 +0800419
Chao Yub691d982016-10-11 22:57:05 +0800420 if (et) {
421 read_lock(&et->lock);
422 set_raw_extent(&et->largest, &ri->i_ext);
423 read_unlock(&et->lock);
424 } else {
Jaegeuk Kim3e72f722015-06-19 17:53:26 -0700425 memset(&ri->i_ext, 0, sizeof(ri->i_ext));
Chao Yub691d982016-10-11 22:57:05 +0800426 }
Jaegeuk Kim91942322016-05-20 10:13:22 -0700427 set_raw_inline(inode, ri);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900428
429 ri->i_atime = cpu_to_le64(inode->i_atime.tv_sec);
430 ri->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec);
431 ri->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec);
432 ri->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
433 ri->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
434 ri->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
Chao Yu1c41e6802018-05-07 20:28:52 +0800435 if (S_ISDIR(inode->i_mode))
436 ri->i_current_depth =
437 cpu_to_le32(F2FS_I(inode)->i_current_depth);
438 else if (S_ISREG(inode->i_mode))
Chao Yu2ef79ec2018-05-07 20:28:54 +0800439 ri->i_gc_failures =
440 cpu_to_le16(F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN]);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900441 ri->i_xattr_nid = cpu_to_le32(F2FS_I(inode)->i_xattr_nid);
442 ri->i_flags = cpu_to_le32(F2FS_I(inode)->i_flags);
Jaegeuk Kim6666e6a2012-12-10 17:52:48 +0900443 ri->i_pino = cpu_to_le32(F2FS_I(inode)->i_pino);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900444 ri->i_generation = cpu_to_le32(inode->i_generation);
Jaegeuk Kim38431542014-02-27 18:20:00 +0900445 ri->i_dir_level = F2FS_I(inode)->i_dir_level;
Changman Lee7d79e752013-01-23 09:40:23 +0900446
Chao Yu5c571322017-07-26 00:01:41 +0800447 if (f2fs_has_extra_attr(inode)) {
Chao Yu7a2af762017-07-19 00:19:06 +0800448 ri->i_extra_isize = cpu_to_le16(F2FS_I(inode)->i_extra_isize);
449
Chao Yu6afc6622017-09-06 21:59:50 +0800450 if (f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(inode)->sb))
451 ri->i_inline_xattr_size =
452 cpu_to_le16(F2FS_I(inode)->i_inline_xattr_size);
453
Chao Yu5c571322017-07-26 00:01:41 +0800454 if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)->sb) &&
455 F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize,
456 i_projid)) {
457 projid_t i_projid;
458
459 i_projid = from_kprojid(&init_user_ns,
460 F2FS_I(inode)->i_projid);
461 ri->i_projid = cpu_to_le32(i_projid);
462 }
Chao Yu1c1d35d2018-01-25 14:54:42 +0800463
464 if (f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)->sb) &&
465 F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize,
466 i_crtime)) {
467 ri->i_crtime =
468 cpu_to_le64(F2FS_I(inode)->i_crtime.tv_sec);
469 ri->i_crtime_nsec =
470 cpu_to_le32(F2FS_I(inode)->i_crtime.tv_nsec);
471 }
Chao Yu5c571322017-07-26 00:01:41 +0800472 }
473
Jaegeuk Kim3d1e3802013-10-08 18:01:51 +0900474 __set_inode_rdev(inode, ri);
Jaegeuk Kim12719ae2016-01-07 13:23:12 -0800475
Jaegeuk Kim2049d4f2016-01-25 05:57:05 -0800476 /* deleted inode */
477 if (inode->i_nlink == 0)
478 clear_inline_node(node_page);
479
Arnd Bergmann24b81df2018-06-20 10:02:19 +0200480 F2FS_I(inode)->i_disk_time[0] = inode->i_atime;
481 F2FS_I(inode)->i_disk_time[1] = inode->i_ctime;
482 F2FS_I(inode)->i_disk_time[2] = inode->i_mtime;
Jaegeuk Kim214c2462018-03-29 22:50:41 -0700483 F2FS_I(inode)->i_disk_time[3] = F2FS_I(inode)->i_crtime;
Weichao Guo54c55c42018-03-09 23:10:21 +0800484
485#ifdef CONFIG_F2FS_CHECK_FS
486 f2fs_inode_chksum_set(F2FS_I_SB(inode), node_page);
487#endif
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900488}
489
Chao Yu4d57b862018-05-30 00:20:41 +0800490void f2fs_update_inode_page(struct inode *inode)
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900491{
Jaegeuk Kim40813632014-09-02 15:31:18 -0700492 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900493 struct page *node_page;
Jaegeuk Kim744602c2014-01-24 09:42:16 +0900494retry:
Chao Yu4d57b862018-05-30 00:20:41 +0800495 node_page = f2fs_get_node_page(sbi, inode->i_ino);
Jaegeuk Kim744602c2014-01-24 09:42:16 +0900496 if (IS_ERR(node_page)) {
497 int err = PTR_ERR(node_page);
498 if (err == -ENOMEM) {
499 cond_resched();
500 goto retry;
501 } else if (err != -ENOENT) {
Jaegeuk Kim38f91ca2016-05-18 14:07:56 -0700502 f2fs_stop_checkpoint(sbi, false);
Jaegeuk Kim744602c2014-01-24 09:42:16 +0900503 }
Yunlei He211a6fa2017-12-05 12:07:47 +0800504 return;
Jaegeuk Kim744602c2014-01-24 09:42:16 +0900505 }
Chao Yu4d57b862018-05-30 00:20:41 +0800506 f2fs_update_inode(inode, node_page);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900507 f2fs_put_page(node_page, 1);
Jaegeuk Kim39936832012-11-22 16:21:29 +0900508}
509
510int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
511{
Jaegeuk Kim40813632014-09-02 15:31:18 -0700512 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900513
514 if (inode->i_ino == F2FS_NODE_INO(sbi) ||
515 inode->i_ino == F2FS_META_INO(sbi))
516 return 0;
517
Jaegeuk Kim91942322016-05-20 10:13:22 -0700518 if (!is_inode_flag_set(inode, FI_DIRTY_INODE))
Jaegeuk Kimb3783872013-06-10 09:17:01 +0900519 return 0;
520
Jaegeuk Kim39936832012-11-22 16:21:29 +0900521 /*
Jaegeuk Kimc5cd29d2015-09-12 11:25:30 -0700522 * We need to balance fs here to prevent from producing dirty node pages
Jaegeuk Kim39936832012-11-22 16:21:29 +0900523 * during the urgent cleaning time when runing out of free sections.
524 */
Chao Yu4d57b862018-05-30 00:20:41 +0800525 f2fs_update_inode_page(inode);
Jaegeuk Kima7881892017-04-20 13:51:57 -0700526 if (wbc && wbc->nr_to_write)
Jaegeuk Kim2c4db1a2016-01-07 14:15:04 -0800527 f2fs_balance_fs(sbi, true);
Jaegeuk Kim744602c2014-01-24 09:42:16 +0900528 return 0;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900529}
530
Jaegeuk Kim0a8165d2012-11-29 13:28:09 +0900531/*
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900532 * Called at the last iput() if i_nlink is zero
533 */
534void f2fs_evict_inode(struct inode *inode)
535{
Jaegeuk Kim40813632014-09-02 15:31:18 -0700536 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kim91942322016-05-20 10:13:22 -0700537 nid_t xnid = F2FS_I(inode)->i_xattr_nid;
Chao Yu13ec7292015-08-24 17:40:45 +0800538 int err = 0;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900539
Jaegeuk Kim88b88a62014-10-06 17:39:50 -0700540 /* some remained atomic pages should discarded */
Jaegeuk Kim1e843712014-12-09 06:08:59 -0800541 if (f2fs_is_atomic_file(inode))
Chao Yu4d57b862018-05-30 00:20:41 +0800542 f2fs_drop_inmem_pages(inode);
Jaegeuk Kim88b88a62014-10-06 17:39:50 -0700543
Namjae Jeona2a4a7e2013-04-20 01:28:40 +0900544 trace_f2fs_evict_inode(inode);
Johannes Weiner91b0abe2014-04-03 14:47:49 -0700545 truncate_inode_pages_final(&inode->i_data);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900546
547 if (inode->i_ino == F2FS_NODE_INO(sbi) ||
548 inode->i_ino == F2FS_META_INO(sbi))
Chao Yudbf20cb2014-07-25 12:00:57 +0800549 goto out_clear;
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900550
Jaegeuk Kima7ffdbe2014-09-12 15:53:45 -0700551 f2fs_bug_on(sbi, get_dirty_pages(inode));
Chao Yu4d57b862018-05-30 00:20:41 +0800552 f2fs_remove_dirty_inode(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900553
Jaegeuk Kim3e72f722015-06-19 17:53:26 -0700554 f2fs_destroy_extent_tree(inode);
555
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900556 if (inode->i_nlink || is_bad_inode(inode))
557 goto no_delete;
558
Chao Yu0abd6752017-07-09 00:13:07 +0800559 dquot_initialize(inode);
560
Chao Yu4d57b862018-05-30 00:20:41 +0800561 f2fs_remove_ino_entry(sbi, inode->i_ino, APPEND_INO);
562 f2fs_remove_ino_entry(sbi, inode->i_ino, UPDATE_INO);
563 f2fs_remove_ino_entry(sbi, inode->i_ino, FLUSH_INO);
Chao Yu60dcedc2016-11-02 20:43:21 +0800564
Changman Leed6212a52013-01-29 18:30:07 +0900565 sb_start_intwrite(inode->i_sb);
Jaegeuk Kim91942322016-05-20 10:13:22 -0700566 set_inode_flag(inode, FI_NO_ALLOC);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900567 i_size_write(inode, 0);
Jaegeuk Kim4c0c2942016-05-03 09:22:18 -0700568retry:
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900569 if (F2FS_HAS_BLOCKS(inode))
Jaegeuk Kim9a449e92016-06-02 13:49:38 -0700570 err = f2fs_truncate(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900571
Jaegeuk Kim8c1b3c02017-03-07 13:32:20 -0800572#ifdef CONFIG_F2FS_FAULT_INJECTION
573 if (time_to_inject(sbi, FAULT_EVICT_INODE)) {
574 f2fs_show_injection_info(FAULT_EVICT_INODE);
575 err = -EIO;
576 }
577#endif
Chao Yu13ec7292015-08-24 17:40:45 +0800578 if (!err) {
579 f2fs_lock_op(sbi);
Chao Yu4d57b862018-05-30 00:20:41 +0800580 err = f2fs_remove_inode_page(inode);
Chao Yu13ec7292015-08-24 17:40:45 +0800581 f2fs_unlock_op(sbi);
Chao Yua11b9f62016-10-11 22:56:59 +0800582 if (err == -ENOENT)
583 err = 0;
Chao Yu13ec7292015-08-24 17:40:45 +0800584 }
Jaegeuk Kim39936832012-11-22 16:21:29 +0900585
Jaegeuk Kim4c0c2942016-05-03 09:22:18 -0700586 /* give more chances, if ENOMEM case */
587 if (err == -ENOMEM) {
588 err = 0;
589 goto retry;
590 }
591
Jaegeuk Kim0f18b462016-05-20 11:10:10 -0700592 if (err)
Chao Yu4d57b862018-05-30 00:20:41 +0800593 f2fs_update_inode_page(inode);
Chao Yu0abd6752017-07-09 00:13:07 +0800594 dquot_free_inode(inode);
Changman Leed6212a52013-01-29 18:30:07 +0900595 sb_end_intwrite(inode->i_sb);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900596no_delete:
Chao Yu0abd6752017-07-09 00:13:07 +0800597 dquot_drop(inode);
598
Chao Yud5e8f6c2015-07-15 17:28:53 +0800599 stat_dec_inline_xattr(inode);
Jaegeuk Kim3289c062014-10-13 20:00:16 -0700600 stat_dec_inline_dir(inode);
Jaegeuk Kime7a2bf22014-10-14 10:29:50 -0700601 stat_dec_inline_inode(inode);
Chao Yu0bdee482015-03-19 19:27:51 +0800602
Jaegeuk Kim943973c2017-10-12 19:12:53 -0700603 if (likely(!is_set_ckpt_flags(sbi, CP_ERROR_FLAG)))
Chao Yuca7d8022017-09-12 14:04:05 +0800604 f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE));
Jaegeuk Kim943973c2017-10-12 19:12:53 -0700605 else
606 f2fs_inode_synced(inode);
Chao Yuca7d8022017-09-12 14:04:05 +0800607
Jaegeuk Kim4f295442017-03-04 13:56:10 -0800608 /* ino == 0, if f2fs_new_inode() was failed t*/
609 if (inode->i_ino)
610 invalidate_mapping_pages(NODE_MAPPING(sbi), inode->i_ino,
611 inode->i_ino);
Chao Yu002a41c2014-08-04 09:54:58 +0800612 if (xnid)
613 invalidate_mapping_pages(NODE_MAPPING(sbi), xnid, xnid);
Chao Yu60dcedc2016-11-02 20:43:21 +0800614 if (inode->i_nlink) {
615 if (is_inode_flag_set(inode, FI_APPEND_WRITE))
Chao Yu4d57b862018-05-30 00:20:41 +0800616 f2fs_add_ino_entry(sbi, inode->i_ino, APPEND_INO);
Chao Yu60dcedc2016-11-02 20:43:21 +0800617 if (is_inode_flag_set(inode, FI_UPDATE_WRITE))
Chao Yu4d57b862018-05-30 00:20:41 +0800618 f2fs_add_ino_entry(sbi, inode->i_ino, UPDATE_INO);
Chao Yu60dcedc2016-11-02 20:43:21 +0800619 }
Jaegeuk Kim91942322016-05-20 10:13:22 -0700620 if (is_inode_flag_set(inode, FI_FREE_NID)) {
Chao Yu4d57b862018-05-30 00:20:41 +0800621 f2fs_alloc_nid_failed(sbi, inode->i_ino);
Jaegeuk Kim91942322016-05-20 10:13:22 -0700622 clear_inode_flag(inode, FI_FREE_NID);
Jaegeuk Kimd8c42562017-06-01 15:39:27 -0700623 } else {
Jaegeuk Kima4f843b2018-04-23 23:02:31 -0600624 /*
625 * If xattr nid is corrupted, we can reach out error condition,
Chao Yu4d57b862018-05-30 00:20:41 +0800626 * err & !f2fs_exist_written_data(sbi, inode->i_ino, ORPHAN_INO)).
627 * In that case, f2fs_check_nid_range() is enough to give a clue.
Jaegeuk Kima4f843b2018-04-23 23:02:31 -0600628 */
Jaegeuk Kimc9b63bd2015-06-23 10:36:08 -0700629 }
Chao Yudbf20cb2014-07-25 12:00:57 +0800630out_clear:
Eric Biggers3d204e22018-01-11 23:30:13 -0500631 fscrypt_put_encryption_info(inode);
Chao Yudbf20cb2014-07-25 12:00:57 +0800632 clear_inode(inode);
Jaegeuk Kim19f99ce2012-11-02 17:10:40 +0900633}
Jaegeuk Kim44c16152014-09-25 11:55:53 -0700634
635/* caller should call f2fs_lock_op() */
Chao Yu4d57b862018-05-30 00:20:41 +0800636void f2fs_handle_failed_inode(struct inode *inode)
Jaegeuk Kim44c16152014-09-25 11:55:53 -0700637{
638 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
Jaegeuk Kim221149c2016-05-02 12:34:48 -0700639 struct node_info ni;
Jaegeuk Kim44c16152014-09-25 11:55:53 -0700640
Chao Yua11b9f62016-10-11 22:56:59 +0800641 /*
642 * clear nlink of inode in order to release resource of inode
643 * immediately.
644 */
645 clear_nlink(inode);
646
647 /*
648 * we must call this to avoid inode being remained as dirty, resulting
649 * in a panic when flushing dirty inodes in gdirty_list.
650 */
Chao Yu4d57b862018-05-30 00:20:41 +0800651 f2fs_update_inode_page(inode);
Jaegeuk Kim9bb02c32017-04-11 19:01:26 -0700652 f2fs_inode_synced(inode);
Chao Yua11b9f62016-10-11 22:56:59 +0800653
Jaegeuk Kim221149c2016-05-02 12:34:48 -0700654 /* don't make bad inode, since it becomes a regular file. */
Jaegeuk Kim44c16152014-09-25 11:55:53 -0700655 unlock_new_inode(inode);
656
Chao Yu13ec7292015-08-24 17:40:45 +0800657 /*
Chao Yu13ec7292015-08-24 17:40:45 +0800658 * Note: we should add inode to orphan list before f2fs_unlock_op()
659 * so we can prevent losing this orphan when encoutering checkpoint
660 * and following suddenly power-off.
661 */
Chao Yu4d57b862018-05-30 00:20:41 +0800662 f2fs_get_node_info(sbi, inode->i_ino, &ni);
Jaegeuk Kim221149c2016-05-02 12:34:48 -0700663
664 if (ni.blk_addr != NULL_ADDR) {
Chao Yu4d57b862018-05-30 00:20:41 +0800665 int err = f2fs_acquire_orphan_inode(sbi);
Jaegeuk Kim221149c2016-05-02 12:34:48 -0700666 if (err) {
667 set_sbi_flag(sbi, SBI_NEED_FSCK);
668 f2fs_msg(sbi->sb, KERN_WARNING,
669 "Too many orphan inodes, run fsck to fix.");
670 } else {
Chao Yu4d57b862018-05-30 00:20:41 +0800671 f2fs_add_orphan_inode(inode);
Jaegeuk Kim221149c2016-05-02 12:34:48 -0700672 }
Chao Yu4d57b862018-05-30 00:20:41 +0800673 f2fs_alloc_nid_done(sbi, inode->i_ino);
Jaegeuk Kim221149c2016-05-02 12:34:48 -0700674 } else {
Jaegeuk Kim91942322016-05-20 10:13:22 -0700675 set_inode_flag(inode, FI_FREE_NID);
Chao Yu13ec7292015-08-24 17:40:45 +0800676 }
Jaegeuk Kim44c16152014-09-25 11:55:53 -0700677
Jaegeuk Kim44c16152014-09-25 11:55:53 -0700678 f2fs_unlock_op(sbi);
679
680 /* iput will drop the inode object */
681 iput(inode);
682}