]> Git Repo - linux.git/blob - fs/exfat/inode.c
net: change addr_list_lock back to static key
[linux.git] / fs / exfat / inode.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
4  */
5
6 #include <linux/init.h>
7 #include <linux/buffer_head.h>
8 #include <linux/mpage.h>
9 #include <linux/bio.h>
10 #include <linux/blkdev.h>
11 #include <linux/time.h>
12 #include <linux/writeback.h>
13 #include <linux/uio.h>
14 #include <linux/random.h>
15 #include <linux/iversion.h>
16
17 #include "exfat_raw.h"
18 #include "exfat_fs.h"
19
20 static int __exfat_write_inode(struct inode *inode, int sync)
21 {
22         int ret = -EIO;
23         unsigned long long on_disk_size;
24         struct exfat_dentry *ep, *ep2;
25         struct exfat_entry_set_cache *es = NULL;
26         struct super_block *sb = inode->i_sb;
27         struct exfat_sb_info *sbi = EXFAT_SB(sb);
28         struct exfat_inode_info *ei = EXFAT_I(inode);
29         bool is_dir = (ei->type == TYPE_DIR) ? true : false;
30
31         if (inode->i_ino == EXFAT_ROOT_INO)
32                 return 0;
33
34         /*
35          * If the indode is already unlinked, there is no need for updating it.
36          */
37         if (ei->dir.dir == DIR_DELETED)
38                 return 0;
39
40         if (is_dir && ei->dir.dir == sbi->root_dir && ei->entry == -1)
41                 return 0;
42
43         exfat_set_vol_flags(sb, VOL_DIRTY);
44
45         /* get the directory entry of given file or directory */
46         es = exfat_get_dentry_set(sb, &(ei->dir), ei->entry, ES_ALL_ENTRIES,
47                 &ep);
48         if (!es)
49                 return -EIO;
50         ep2 = ep + 1;
51
52         ep->dentry.file.attr = cpu_to_le16(exfat_make_attr(inode));
53
54         /* set FILE_INFO structure using the acquired struct exfat_dentry */
55         exfat_set_entry_time(sbi, &ei->i_crtime,
56                         &ep->dentry.file.create_tz,
57                         &ep->dentry.file.create_time,
58                         &ep->dentry.file.create_date,
59                         &ep->dentry.file.create_time_ms);
60         exfat_set_entry_time(sbi, &inode->i_mtime,
61                         &ep->dentry.file.modify_tz,
62                         &ep->dentry.file.modify_time,
63                         &ep->dentry.file.modify_date,
64                         &ep->dentry.file.modify_time_ms);
65         exfat_set_entry_time(sbi, &inode->i_atime,
66                         &ep->dentry.file.access_tz,
67                         &ep->dentry.file.access_time,
68                         &ep->dentry.file.access_date,
69                         NULL);
70
71         /* File size should be zero if there is no cluster allocated */
72         on_disk_size = i_size_read(inode);
73
74         if (ei->start_clu == EXFAT_EOF_CLUSTER)
75                 on_disk_size = 0;
76
77         ep2->dentry.stream.valid_size = cpu_to_le64(on_disk_size);
78         ep2->dentry.stream.size = ep2->dentry.stream.valid_size;
79
80         ret = exfat_update_dir_chksum_with_entry_set(sb, es, sync);
81         kfree(es);
82         return ret;
83 }
84
85 int exfat_write_inode(struct inode *inode, struct writeback_control *wbc)
86 {
87         int ret;
88
89         mutex_lock(&EXFAT_SB(inode->i_sb)->s_lock);
90         ret = __exfat_write_inode(inode, wbc->sync_mode == WB_SYNC_ALL);
91         mutex_unlock(&EXFAT_SB(inode->i_sb)->s_lock);
92
93         return ret;
94 }
95
96 void exfat_sync_inode(struct inode *inode)
97 {
98         lockdep_assert_held(&EXFAT_SB(inode->i_sb)->s_lock);
99         __exfat_write_inode(inode, 1);
100 }
101
102 /*
103  * Input: inode, (logical) clu_offset, target allocation area
104  * Output: errcode, cluster number
105  * *clu = (~0), if it's unable to allocate a new cluster
106  */
107 static int exfat_map_cluster(struct inode *inode, unsigned int clu_offset,
108                 unsigned int *clu, int create)
109 {
110         int ret, modified = false;
111         unsigned int last_clu;
112         struct exfat_chain new_clu;
113         struct exfat_dentry *ep;
114         struct exfat_entry_set_cache *es = NULL;
115         struct super_block *sb = inode->i_sb;
116         struct exfat_sb_info *sbi = EXFAT_SB(sb);
117         struct exfat_inode_info *ei = EXFAT_I(inode);
118         unsigned int local_clu_offset = clu_offset;
119         unsigned int num_to_be_allocated = 0, num_clusters = 0;
120
121         ei->rwoffset = EXFAT_CLU_TO_B(clu_offset, sbi);
122
123         if (EXFAT_I(inode)->i_size_ondisk > 0)
124                 num_clusters =
125                         EXFAT_B_TO_CLU_ROUND_UP(EXFAT_I(inode)->i_size_ondisk,
126                         sbi);
127
128         if (clu_offset >= num_clusters)
129                 num_to_be_allocated = clu_offset - num_clusters + 1;
130
131         if (!create && (num_to_be_allocated > 0)) {
132                 *clu = EXFAT_EOF_CLUSTER;
133                 return 0;
134         }
135
136         *clu = last_clu = ei->start_clu;
137
138         if (ei->flags == ALLOC_NO_FAT_CHAIN) {
139                 if (clu_offset > 0 && *clu != EXFAT_EOF_CLUSTER) {
140                         last_clu += clu_offset - 1;
141
142                         if (clu_offset == num_clusters)
143                                 *clu = EXFAT_EOF_CLUSTER;
144                         else
145                                 *clu += clu_offset;
146                 }
147         } else if (ei->type == TYPE_FILE) {
148                 unsigned int fclus = 0;
149                 int err = exfat_get_cluster(inode, clu_offset,
150                                 &fclus, clu, &last_clu, 1);
151                 if (err)
152                         return -EIO;
153
154                 clu_offset -= fclus;
155         } else {
156                 /* hint information */
157                 if (clu_offset > 0 && ei->hint_bmap.off != EXFAT_EOF_CLUSTER &&
158                     ei->hint_bmap.off > 0 && clu_offset >= ei->hint_bmap.off) {
159                         clu_offset -= ei->hint_bmap.off;
160                         /* hint_bmap.clu should be valid */
161                         WARN_ON(ei->hint_bmap.clu < 2);
162                         *clu = ei->hint_bmap.clu;
163                 }
164
165                 while (clu_offset > 0 && *clu != EXFAT_EOF_CLUSTER) {
166                         last_clu = *clu;
167                         if (exfat_get_next_cluster(sb, clu))
168                                 return -EIO;
169                         clu_offset--;
170                 }
171         }
172
173         if (*clu == EXFAT_EOF_CLUSTER) {
174                 exfat_set_vol_flags(sb, VOL_DIRTY);
175
176                 new_clu.dir = (last_clu == EXFAT_EOF_CLUSTER) ?
177                                 EXFAT_EOF_CLUSTER : last_clu + 1;
178                 new_clu.size = 0;
179                 new_clu.flags = ei->flags;
180
181                 /* allocate a cluster */
182                 if (num_to_be_allocated < 1) {
183                         /* Broken FAT (i_sze > allocated FAT) */
184                         exfat_fs_error(sb, "broken FAT chain.");
185                         return -EIO;
186                 }
187
188                 ret = exfat_alloc_cluster(inode, num_to_be_allocated, &new_clu);
189                 if (ret)
190                         return ret;
191
192                 if (new_clu.dir == EXFAT_EOF_CLUSTER ||
193                     new_clu.dir == EXFAT_FREE_CLUSTER) {
194                         exfat_fs_error(sb,
195                                 "bogus cluster new allocated (last_clu : %u, new_clu : %u)",
196                                 last_clu, new_clu.dir);
197                         return -EIO;
198                 }
199
200                 /* append to the FAT chain */
201                 if (last_clu == EXFAT_EOF_CLUSTER) {
202                         if (new_clu.flags == ALLOC_FAT_CHAIN)
203                                 ei->flags = ALLOC_FAT_CHAIN;
204                         ei->start_clu = new_clu.dir;
205                         modified = true;
206                 } else {
207                         if (new_clu.flags != ei->flags) {
208                                 /* no-fat-chain bit is disabled,
209                                  * so fat-chain should be synced with
210                                  * alloc-bitmap
211                                  */
212                                 exfat_chain_cont_cluster(sb, ei->start_clu,
213                                         num_clusters);
214                                 ei->flags = ALLOC_FAT_CHAIN;
215                                 modified = true;
216                         }
217                         if (new_clu.flags == ALLOC_FAT_CHAIN)
218                                 if (exfat_ent_set(sb, last_clu, new_clu.dir))
219                                         return -EIO;
220                 }
221
222                 num_clusters += num_to_be_allocated;
223                 *clu = new_clu.dir;
224
225                 if (ei->dir.dir != DIR_DELETED) {
226                         es = exfat_get_dentry_set(sb, &(ei->dir), ei->entry,
227                                 ES_ALL_ENTRIES, &ep);
228                         if (!es)
229                                 return -EIO;
230                         /* get stream entry */
231                         ep++;
232
233                         /* update directory entry */
234                         if (modified) {
235                                 if (ep->dentry.stream.flags != ei->flags)
236                                         ep->dentry.stream.flags = ei->flags;
237
238                                 if (le32_to_cpu(ep->dentry.stream.start_clu) !=
239                                                 ei->start_clu)
240                                         ep->dentry.stream.start_clu =
241                                                 cpu_to_le32(ei->start_clu);
242
243                                 ep->dentry.stream.valid_size =
244                                         cpu_to_le64(i_size_read(inode));
245                                 ep->dentry.stream.size =
246                                         ep->dentry.stream.valid_size;
247                         }
248
249                         if (exfat_update_dir_chksum_with_entry_set(sb, es,
250                             inode_needs_sync(inode)))
251                                 return -EIO;
252                         kfree(es);
253
254                 } /* end of if != DIR_DELETED */
255
256                 inode->i_blocks +=
257                         num_to_be_allocated << sbi->sect_per_clus_bits;
258
259                 /*
260                  * Move *clu pointer along FAT chains (hole care) because the
261                  * caller of this function expect *clu to be the last cluster.
262                  * This only works when num_to_be_allocated >= 2,
263                  * *clu = (the first cluster of the allocated chain) =>
264                  * (the last cluster of ...)
265                  */
266                 if (ei->flags == ALLOC_NO_FAT_CHAIN) {
267                         *clu += num_to_be_allocated - 1;
268                 } else {
269                         while (num_to_be_allocated > 1) {
270                                 if (exfat_get_next_cluster(sb, clu))
271                                         return -EIO;
272                                 num_to_be_allocated--;
273                         }
274                 }
275
276         }
277
278         /* hint information */
279         ei->hint_bmap.off = local_clu_offset;
280         ei->hint_bmap.clu = *clu;
281
282         return 0;
283 }
284
285 static int exfat_map_new_buffer(struct exfat_inode_info *ei,
286                 struct buffer_head *bh, loff_t pos)
287 {
288         if (buffer_delay(bh) && pos > ei->i_size_aligned)
289                 return -EIO;
290         set_buffer_new(bh);
291
292         /*
293          * Adjust i_size_aligned if i_size_ondisk is bigger than it.
294          */
295         if (ei->i_size_ondisk > ei->i_size_aligned)
296                 ei->i_size_aligned = ei->i_size_ondisk;
297         return 0;
298 }
299
300 static int exfat_get_block(struct inode *inode, sector_t iblock,
301                 struct buffer_head *bh_result, int create)
302 {
303         struct exfat_inode_info *ei = EXFAT_I(inode);
304         struct super_block *sb = inode->i_sb;
305         struct exfat_sb_info *sbi = EXFAT_SB(sb);
306         unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
307         int err = 0;
308         unsigned long mapped_blocks = 0;
309         unsigned int cluster, sec_offset;
310         sector_t last_block;
311         sector_t phys = 0;
312         loff_t pos;
313
314         mutex_lock(&sbi->s_lock);
315         last_block = EXFAT_B_TO_BLK_ROUND_UP(i_size_read(inode), sb);
316         if (iblock >= last_block && !create)
317                 goto done;
318
319         /* Is this block already allocated? */
320         err = exfat_map_cluster(inode, iblock >> sbi->sect_per_clus_bits,
321                         &cluster, create);
322         if (err) {
323                 if (err != -ENOSPC)
324                         exfat_fs_error_ratelimit(sb,
325                                 "failed to bmap (inode : %p iblock : %llu, err : %d)",
326                                 inode, (unsigned long long)iblock, err);
327                 goto unlock_ret;
328         }
329
330         if (cluster == EXFAT_EOF_CLUSTER)
331                 goto done;
332
333         /* sector offset in cluster */
334         sec_offset = iblock & (sbi->sect_per_clus - 1);
335
336         phys = exfat_cluster_to_sector(sbi, cluster) + sec_offset;
337         mapped_blocks = sbi->sect_per_clus - sec_offset;
338         max_blocks = min(mapped_blocks, max_blocks);
339
340         /* Treat newly added block / cluster */
341         if (iblock < last_block)
342                 create = 0;
343
344         if (create || buffer_delay(bh_result)) {
345                 pos = EXFAT_BLK_TO_B((iblock + 1), sb);
346                 if (ei->i_size_ondisk < pos)
347                         ei->i_size_ondisk = pos;
348         }
349
350         if (create) {
351                 err = exfat_map_new_buffer(ei, bh_result, pos);
352                 if (err) {
353                         exfat_fs_error(sb,
354                                         "requested for bmap out of range(pos : (%llu) > i_size_aligned(%llu)\n",
355                                         pos, ei->i_size_aligned);
356                         goto unlock_ret;
357                 }
358         }
359
360         if (buffer_delay(bh_result))
361                 clear_buffer_delay(bh_result);
362         map_bh(bh_result, sb, phys);
363 done:
364         bh_result->b_size = EXFAT_BLK_TO_B(max_blocks, sb);
365 unlock_ret:
366         mutex_unlock(&sbi->s_lock);
367         return err;
368 }
369
370 static int exfat_readpage(struct file *file, struct page *page)
371 {
372         return mpage_readpage(page, exfat_get_block);
373 }
374
375 static void exfat_readahead(struct readahead_control *rac)
376 {
377         mpage_readahead(rac, exfat_get_block);
378 }
379
380 static int exfat_writepage(struct page *page, struct writeback_control *wbc)
381 {
382         return block_write_full_page(page, exfat_get_block, wbc);
383 }
384
385 static int exfat_writepages(struct address_space *mapping,
386                 struct writeback_control *wbc)
387 {
388         return mpage_writepages(mapping, wbc, exfat_get_block);
389 }
390
391 static void exfat_write_failed(struct address_space *mapping, loff_t to)
392 {
393         struct inode *inode = mapping->host;
394
395         if (to > i_size_read(inode)) {
396                 truncate_pagecache(inode, i_size_read(inode));
397                 exfat_truncate(inode, EXFAT_I(inode)->i_size_aligned);
398         }
399 }
400
401 static int exfat_write_begin(struct file *file, struct address_space *mapping,
402                 loff_t pos, unsigned int len, unsigned int flags,
403                 struct page **pagep, void **fsdata)
404 {
405         int ret;
406
407         *pagep = NULL;
408         ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
409                                exfat_get_block,
410                                &EXFAT_I(mapping->host)->i_size_ondisk);
411
412         if (ret < 0)
413                 exfat_write_failed(mapping, pos+len);
414
415         return ret;
416 }
417
418 static int exfat_write_end(struct file *file, struct address_space *mapping,
419                 loff_t pos, unsigned int len, unsigned int copied,
420                 struct page *pagep, void *fsdata)
421 {
422         struct inode *inode = mapping->host;
423         struct exfat_inode_info *ei = EXFAT_I(inode);
424         int err;
425
426         err = generic_write_end(file, mapping, pos, len, copied, pagep, fsdata);
427
428         if (EXFAT_I(inode)->i_size_aligned < i_size_read(inode)) {
429                 exfat_fs_error(inode->i_sb,
430                         "invalid size(size(%llu) > aligned(%llu)\n",
431                         i_size_read(inode), EXFAT_I(inode)->i_size_aligned);
432                 return -EIO;
433         }
434
435         if (err < len)
436                 exfat_write_failed(mapping, pos+len);
437
438         if (!(err < 0) && !(ei->attr & ATTR_ARCHIVE)) {
439                 inode->i_mtime = inode->i_ctime = current_time(inode);
440                 ei->attr |= ATTR_ARCHIVE;
441                 mark_inode_dirty(inode);
442         }
443
444         return err;
445 }
446
447 static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
448 {
449         struct address_space *mapping = iocb->ki_filp->f_mapping;
450         struct inode *inode = mapping->host;
451         loff_t size = iocb->ki_pos + iov_iter_count(iter);
452         int rw = iov_iter_rw(iter);
453         ssize_t ret;
454
455         if (rw == WRITE) {
456                 /*
457                  * FIXME: blockdev_direct_IO() doesn't use ->write_begin(),
458                  * so we need to update the ->i_size_aligned to block boundary.
459                  *
460                  * But we must fill the remaining area or hole by nul for
461                  * updating ->i_size_aligned
462                  *
463                  * Return 0, and fallback to normal buffered write.
464                  */
465                 if (EXFAT_I(inode)->i_size_aligned < size)
466                         return 0;
467         }
468
469         /*
470          * Need to use the DIO_LOCKING for avoiding the race
471          * condition of exfat_get_block() and ->truncate().
472          */
473         ret = blockdev_direct_IO(iocb, inode, iter, exfat_get_block);
474         if (ret < 0 && (rw & WRITE))
475                 exfat_write_failed(mapping, size);
476         return ret;
477 }
478
479 static sector_t exfat_aop_bmap(struct address_space *mapping, sector_t block)
480 {
481         sector_t blocknr;
482
483         /* exfat_get_cluster() assumes the requested blocknr isn't truncated. */
484         down_read(&EXFAT_I(mapping->host)->truncate_lock);
485         blocknr = generic_block_bmap(mapping, block, exfat_get_block);
486         up_read(&EXFAT_I(mapping->host)->truncate_lock);
487         return blocknr;
488 }
489
490 /*
491  * exfat_block_truncate_page() zeroes out a mapping from file offset `from'
492  * up to the end of the block which corresponds to `from'.
493  * This is required during truncate to physically zeroout the tail end
494  * of that block so it doesn't yield old data if the file is later grown.
495  * Also, avoid causing failure from fsx for cases of "data past EOF"
496  */
497 int exfat_block_truncate_page(struct inode *inode, loff_t from)
498 {
499         return block_truncate_page(inode->i_mapping, from, exfat_get_block);
500 }
501
502 static const struct address_space_operations exfat_aops = {
503         .readpage       = exfat_readpage,
504         .readahead      = exfat_readahead,
505         .writepage      = exfat_writepage,
506         .writepages     = exfat_writepages,
507         .write_begin    = exfat_write_begin,
508         .write_end      = exfat_write_end,
509         .direct_IO      = exfat_direct_IO,
510         .bmap           = exfat_aop_bmap
511 };
512
513 static inline unsigned long exfat_hash(loff_t i_pos)
514 {
515         return hash_32(i_pos, EXFAT_HASH_BITS);
516 }
517
518 void exfat_hash_inode(struct inode *inode, loff_t i_pos)
519 {
520         struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
521         struct hlist_head *head = sbi->inode_hashtable + exfat_hash(i_pos);
522
523         spin_lock(&sbi->inode_hash_lock);
524         EXFAT_I(inode)->i_pos = i_pos;
525         hlist_add_head(&EXFAT_I(inode)->i_hash_fat, head);
526         spin_unlock(&sbi->inode_hash_lock);
527 }
528
529 void exfat_unhash_inode(struct inode *inode)
530 {
531         struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
532
533         spin_lock(&sbi->inode_hash_lock);
534         hlist_del_init(&EXFAT_I(inode)->i_hash_fat);
535         EXFAT_I(inode)->i_pos = 0;
536         spin_unlock(&sbi->inode_hash_lock);
537 }
538
539 struct inode *exfat_iget(struct super_block *sb, loff_t i_pos)
540 {
541         struct exfat_sb_info *sbi = EXFAT_SB(sb);
542         struct exfat_inode_info *info;
543         struct hlist_head *head = sbi->inode_hashtable + exfat_hash(i_pos);
544         struct inode *inode = NULL;
545
546         spin_lock(&sbi->inode_hash_lock);
547         hlist_for_each_entry(info, head, i_hash_fat) {
548                 WARN_ON(info->vfs_inode.i_sb != sb);
549
550                 if (i_pos != info->i_pos)
551                         continue;
552                 inode = igrab(&info->vfs_inode);
553                 if (inode)
554                         break;
555         }
556         spin_unlock(&sbi->inode_hash_lock);
557         return inode;
558 }
559
560 /* doesn't deal with root inode */
561 static int exfat_fill_inode(struct inode *inode, struct exfat_dir_entry *info)
562 {
563         struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
564         struct exfat_inode_info *ei = EXFAT_I(inode);
565         loff_t size = info->size;
566
567         memcpy(&ei->dir, &info->dir, sizeof(struct exfat_chain));
568         ei->entry = info->entry;
569         ei->attr = info->attr;
570         ei->start_clu = info->start_clu;
571         ei->flags = info->flags;
572         ei->type = info->type;
573
574         ei->version = 0;
575         ei->hint_stat.eidx = 0;
576         ei->hint_stat.clu = info->start_clu;
577         ei->hint_femp.eidx = EXFAT_HINT_NONE;
578         ei->rwoffset = 0;
579         ei->hint_bmap.off = EXFAT_EOF_CLUSTER;
580         ei->i_pos = 0;
581
582         inode->i_uid = sbi->options.fs_uid;
583         inode->i_gid = sbi->options.fs_gid;
584         inode_inc_iversion(inode);
585         inode->i_generation = prandom_u32();
586
587         if (info->attr & ATTR_SUBDIR) { /* directory */
588                 inode->i_generation &= ~1;
589                 inode->i_mode = exfat_make_mode(sbi, info->attr, 0777);
590                 inode->i_op = &exfat_dir_inode_operations;
591                 inode->i_fop = &exfat_dir_operations;
592                 set_nlink(inode, info->num_subdirs);
593         } else { /* regular file */
594                 inode->i_generation |= 1;
595                 inode->i_mode = exfat_make_mode(sbi, info->attr, 0777);
596                 inode->i_op = &exfat_file_inode_operations;
597                 inode->i_fop = &exfat_file_operations;
598                 inode->i_mapping->a_ops = &exfat_aops;
599                 inode->i_mapping->nrpages = 0;
600         }
601
602         i_size_write(inode, size);
603
604         /* ondisk and aligned size should be aligned with block size */
605         if (size & (inode->i_sb->s_blocksize - 1)) {
606                 size |= (inode->i_sb->s_blocksize - 1);
607                 size++;
608         }
609
610         ei->i_size_aligned = size;
611         ei->i_size_ondisk = size;
612
613         exfat_save_attr(inode, info->attr);
614
615         inode->i_blocks = ((i_size_read(inode) + (sbi->cluster_size - 1)) &
616                 ~(sbi->cluster_size - 1)) >> inode->i_blkbits;
617         inode->i_mtime = info->mtime;
618         inode->i_ctime = info->mtime;
619         ei->i_crtime = info->crtime;
620         inode->i_atime = info->atime;
621
622         exfat_cache_init_inode(inode);
623
624         return 0;
625 }
626
627 struct inode *exfat_build_inode(struct super_block *sb,
628                 struct exfat_dir_entry *info, loff_t i_pos)
629 {
630         struct inode *inode;
631         int err;
632
633         inode = exfat_iget(sb, i_pos);
634         if (inode)
635                 goto out;
636         inode = new_inode(sb);
637         if (!inode) {
638                 inode = ERR_PTR(-ENOMEM);
639                 goto out;
640         }
641         inode->i_ino = iunique(sb, EXFAT_ROOT_INO);
642         inode_set_iversion(inode, 1);
643         err = exfat_fill_inode(inode, info);
644         if (err) {
645                 iput(inode);
646                 inode = ERR_PTR(err);
647                 goto out;
648         }
649         exfat_hash_inode(inode, i_pos);
650         insert_inode_hash(inode);
651 out:
652         return inode;
653 }
654
655 void exfat_evict_inode(struct inode *inode)
656 {
657         truncate_inode_pages(&inode->i_data, 0);
658
659         if (!inode->i_nlink) {
660                 i_size_write(inode, 0);
661                 mutex_lock(&EXFAT_SB(inode->i_sb)->s_lock);
662                 __exfat_truncate(inode, 0);
663                 mutex_unlock(&EXFAT_SB(inode->i_sb)->s_lock);
664         }
665
666         invalidate_inode_buffers(inode);
667         clear_inode(inode);
668         exfat_cache_inval_inode(inode);
669         exfat_unhash_inode(inode);
670 }
This page took 0.080188 seconds and 4 git commands to generate.