Lines Matching +full:trim +full:- +full:data +full:- +full:valid

1 /* SPDX-License-Identifier: GPL-2.0 */
4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
8 // clang-format off
19 #include <linux/page-flags.h>
42 #define MINUS_ONE_T ((size_t)(-1))
54 /* NTFS specific error code about resident->nonresident. */
58 /* NTFS specific error code when on-disk struct is corrupted. */
62 /* sbi->flags */
73 /* ni->ni_flags */
75 * Data attribute is external compressed (LZX/Xpress)
76 * 1 - WOF_COMPRESSION_XPRESS4K
77 * 2 - WOF_COMPRESSION_XPRESS8K
78 * 3 - WOF_COMPRESSION_XPRESS16K
79 * 4 - WOF_COMPRESSION_LZX32K
82 /* Data attribute is deduplicated. */
88 // clang-format on
160 * -1 Tree is activated but not updated (too many fragments).
161 * 0 - Tree is not activated.
162 * 1 - Tree is activated and updated.
188 /* ntfs_index - Allocation unit inside directory. */
198 u8 index_bits; // log2(root->index_block_size)
199 u8 idx2vbn_bits; // log2(root->index_block_clst)
209 /* Ntfs file system in-core superblock data. */
214 u64 discard_granularity_mask_inv; // ~(discard_granularity_mask_inv-1)
215 u32 bdev_blocksize_mask; // bdev_logical_block_size(bdev) - 1;
218 u32 cluster_mask; // == cluster_size - 1
219 u64 cluster_mask_inv; // ~(cluster_size - 1)
220 u32 block_mask; // sb->s_blocksize - 1
221 u32 blocks_per_cluster; // cluster_size / sb->s_blocksize
259 * MFT records [11-24) used to expand MFT itself.
263 ulong reserved_bitmap; // Bitmap of used records [11 - 24)
265 size_t used; // MFT valid size in records.
272 struct wnd_bitmap bitmap; // $Bitmap::Data
350 * Ntfs inode - extends linux inode. consists of one or more MFT inodes.
356 * Valid size: [0 - i_valid) - these range in file contains valid data.
357 * Range [i_valid - inode->i_size) - contains 0.
358 * Usually i_valid <= inode->i_size.
383 * If inode is bad during initialization - use make_bad_inode
384 * If inode is bad during operations - use this field
673 void mark_as_free_ex(struct ntfs_sb_info *sbi, CLST lcn, CLST len, bool trim);
675 bool trim);
732 int inode_read_data(struct inode *inode, void *data, size_t bytes);
767 return mi_find_attr(ni, rec, NULL, le->type, le_name(le), le->name_len,
768 &le->id);
785 if (le32_to_cpu(ref->low) != mi->rno)
787 if (ref->seq != mi->mrec->seq)
791 return le16_to_cpu(ref->high) == (mi->rno >> 32);
793 return !ref->high;
799 ref->low = cpu_to_le32(mi->rno);
801 ref->high = cpu_to_le16(mi->rno >> 32);
803 ref->high = 0;
805 ref->seq = mi->mrec->seq;
850 return wnd->total_zeroes;
911 return sbi->volume.major_ver >= 3;
914 /* (sb->s_flags & SB_ACTIVE) */
917 return !!sbi->sb->s_root;
922 return rno < MFT_REC_FREE || rno == sbi->objid_no ||
923 rno == sbi->quota_no || rno == sbi->reparse_no ||
924 rno == sbi->usn_jrnl_no;
929 return wnd->zone_bit;
934 return wnd->zone_end - wnd->zone_bit;
939 run->runs = NULL;
940 run->count = 0;
941 run->allocated = 0;
951 kvfree(run->runs);
958 kvfree(run->runs);
965 return !run->count;
980 * kernel2nt - Converts in-memory kernel timestamp into nt time.
986 (ts->tv_sec + SecondsToStartOf1970) +
987 ts->tv_nsec / NTFS_TIME_GRAN);
991 * nt2kernel - Converts on-disk nt time into kernel timestamp.
997 s64 t = le64_to_cpu(tm) - _100ns2seconds * SecondsToStartOf1970;
999 ts->tv_sec = div_s64_rem(t, _100ns2seconds, &t32);
1000 ts->tv_nsec = t32 * 100;
1005 return sb->s_fs_info;
1010 return test_bit(NTFS_FLAGS_SHUTDOWN_BIT, &ntfs_sb(sb)->flags);
1014 * ntfs_up_cluster - Align up on cluster boundary.
1018 return (size + sbi->cluster_mask) & sbi->cluster_mask_inv;
1022 * ntfs_up_block - Align up on cluster boundary.
1026 return (size + sb->s_blocksize - 1) & ~(u64)(sb->s_blocksize - 1);
1031 return (size + sbi->cluster_mask) >> sbi->cluster_bits;
1036 return (size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
1046 return (ni->std_fa & FILE_ATTRIBUTE_COMPRESSED) ||
1047 (ni->ni_flags & NI_FLAG_COMPRESSED_MASK);
1052 return ni->ni_bad;
1057 return 0xb + (ni->ni_flags & NI_FLAG_COMPRESSED_MASK);
1060 /* Bits - 0xc, 0xd, 0xe, 0xf, 0x10 */
1063 ni->ni_flags |= (bits - 0xb) & NI_FLAG_COMPRESSED_MASK;
1068 return ni->ni_flags & NI_FLAG_DEDUPLICATED;
1073 return ni->std_fa & FILE_ATTRIBUTE_ENCRYPTED;
1078 return ni->std_fa & FILE_ATTRIBUTE_SPARSE_FILE;
1083 return ni->ni_flags & NI_FLAG_RESIDENT;
1088 *var = cpu_to_le16(le16_to_cpu(*var) - val);
1093 *var = cpu_to_le32(le32_to_cpu(*var) - val);
1098 u32 i, nbufs = nb->nbufs;
1104 put_bh(nb->bh[i]);
1105 nb->nbufs = 0;
1113 kfree(in->index);
1114 nb_put(&in->nb);
1120 nb_put(&mi->nb);
1121 kfree(mi->mrec);
1122 mi->mrec = NULL;
1127 mutex_lock_nested(&ni->ni_lock, NTFS_INODE_MUTEX_NORMAL);
1132 mutex_lock_nested(&ni->ni_lock, NTFS_INODE_MUTEX_PARENT);
1137 mutex_lock_nested(&ni->ni_lock, NTFS_INODE_MUTEX_PARENT2);
1142 mutex_unlock(&ni->ni_lock);
1147 return mutex_trylock(&ni->ni_lock);
1154 return attr_load_runs_vcn(ni, attr->type, attr_name(attr),
1155 attr->name_len, run, vcn);
1160 *var = cpu_to_le64(le64_to_cpu(*var) - val);