Lines Matching +full:value +full:- +full:start

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2004-2005 Anton Altaparmakov
24 u64 start_cluster = ntfs_bytes_to_cluster(vol, range->start); in ntfs_trim_fs()
25 u32 dq = bdev_discard_granularity(vol->sb->s_bdev); in ntfs_trim_fs()
29 dq = vol->cluster_size; in ntfs_trim_fs()
31 if (start_cluster >= vol->nr_clusters) in ntfs_trim_fs()
32 return -EINVAL; in ntfs_trim_fs()
34 if (range->len == (u64)-1) in ntfs_trim_fs()
35 end_cluster = vol->nr_clusters; in ntfs_trim_fs()
38 (range->start + range->len + vol->cluster_size - 1)); in ntfs_trim_fs()
39 if (end_cluster > vol->nr_clusters) in ntfs_trim_fs()
40 end_cluster = vol->nr_clusters; in ntfs_trim_fs()
45 return -ENOMEM; in ntfs_trim_fs()
49 end_index = (end_cluster + buf_clusters - 1) >> 15; in ntfs_trim_fs()
52 folio = ntfs_get_locked_folio(vol->lcnbmp_ino->i_mapping, in ntfs_trim_fs()
68 u64 start = find_next_zero_bit(bitmap, end_buf - start_buf, in ntfs_trim_fs() local
69 end - start_buf) + start_buf; in ntfs_trim_fs()
70 if (start >= end_buf) in ntfs_trim_fs()
73 end = find_next_bit(bitmap, end_buf - start_buf, in ntfs_trim_fs()
74 start - start_buf) + start_buf; in ntfs_trim_fs()
76 aligned_start = ALIGN(ntfs_cluster_to_bytes(vol, start), dq); in ntfs_trim_fs()
78 ALIGN_DOWN(ntfs_cluster_to_bytes(vol, end - start), dq); in ntfs_trim_fs()
79 if (aligned_count >= range->minlen) { in ntfs_trim_fs()
80 ret = blkdev_issue_discard(vol->sb->s_bdev, aligned_start >> 9, in ntfs_trim_fs()
97 range->len = trimmed; in ntfs_trim_fs()
105 * __ntfs_bitmap_set_bits_in_run - set a run of bits in a bitmap to a value
109 * @value: value to set the bits to (i.e. 0 or 1)
113 * vfs inode @vi to @value, where @value is either 0 or 1.
118 * Return 0 on success and -errno on error.
121 const s64 count, const u8 value, const bool is_rollback) in __ntfs_bitmap_set_bits_in_run() argument
131 struct ntfs_volume *vol = ni->vol; in __ntfs_bitmap_set_bits_in_run()
133 ntfs_debug("Entering for i_ino 0x%llx, start_bit 0x%llx, count 0x%llx, value %u.%s", in __ntfs_bitmap_set_bits_in_run()
134 ni->mft_no, (unsigned long long)start_bit, in __ntfs_bitmap_set_bits_in_run()
135 (unsigned long long)cnt, (unsigned int)value, in __ntfs_bitmap_set_bits_in_run()
138 if (start_bit < 0 || cnt < 0 || value > 1) in __ntfs_bitmap_set_bits_in_run()
139 return -EINVAL; in __ntfs_bitmap_set_bits_in_run()
143 * bits, i.e. @start_bit and @start_bit + @cnt - 1, respectively. in __ntfs_bitmap_set_bits_in_run()
146 end_index = (start_bit + cnt - 1) >> (3 + PAGE_SHIFT); in __ntfs_bitmap_set_bits_in_run()
149 mapping = vi->i_mapping; in __ntfs_bitmap_set_bits_in_run()
153 ntfs_error(vi->i_sb, in __ntfs_bitmap_set_bits_in_run()
172 if (ni->mft_no == FILE_Bitmap) in __ntfs_bitmap_set_bits_in_run()
173 ntfs_set_lcn_empty_bits(vol, index, value, min_t(s64, 8 - bit, cnt)); in __ntfs_bitmap_set_bits_in_run()
175 cnt--; in __ntfs_bitmap_set_bits_in_run()
176 if (value) in __ntfs_bitmap_set_bits_in_run()
189 * Depending on @value, modify all remaining whole bytes in the page up in __ntfs_bitmap_set_bits_in_run()
192 len = min_t(s64, cnt >> 3, PAGE_SIZE - pos); in __ntfs_bitmap_set_bits_in_run()
193 memset(kaddr + pos, value ? 0xff : 0, len); in __ntfs_bitmap_set_bits_in_run()
194 cnt -= len << 3; in __ntfs_bitmap_set_bits_in_run()
195 if (ni->mft_no == FILE_Bitmap) in __ntfs_bitmap_set_bits_in_run()
196 ntfs_set_lcn_empty_bits(vol, index, value, len << 3); in __ntfs_bitmap_set_bits_in_run()
198 /* Update @len to point to the first not-done byte in the page. */ in __ntfs_bitmap_set_bits_in_run()
205 err = -EIO; in __ntfs_bitmap_set_bits_in_run()
216 ntfs_error(vi->i_sb, in __ntfs_bitmap_set_bits_in_run()
226 * Depending on @value, modify all remaining whole bytes in the in __ntfs_bitmap_set_bits_in_run()
230 memset(kaddr, value ? 0xff : 0, len); in __ntfs_bitmap_set_bits_in_run()
231 cnt -= len << 3; in __ntfs_bitmap_set_bits_in_run()
232 if (ni->mft_no == FILE_Bitmap) in __ntfs_bitmap_set_bits_in_run()
233 ntfs_set_lcn_empty_bits(vol, index, value, len << 3); in __ntfs_bitmap_set_bits_in_run()
247 if (ni->mft_no == FILE_Bitmap) in __ntfs_bitmap_set_bits_in_run()
248 ntfs_set_lcn_empty_bits(vol, index, value, bit); in __ntfs_bitmap_set_bits_in_run()
249 while (bit--) { in __ntfs_bitmap_set_bits_in_run()
250 if (value) in __ntfs_bitmap_set_bits_in_run()
267 * - no pages are mapped in __ntfs_bitmap_set_bits_in_run()
268 * - @count - @cnt is the number of bits that have been modified in __ntfs_bitmap_set_bits_in_run()
273 pos = __ntfs_bitmap_set_bits_in_run(vi, start_bit, count - cnt, in __ntfs_bitmap_set_bits_in_run()
274 value ? 0 : 1, true); in __ntfs_bitmap_set_bits_in_run()
279 ntfs_error(vi->i_sb, in __ntfs_bitmap_set_bits_in_run()
284 ntfs_error(vi->i_sb, in __ntfs_bitmap_set_bits_in_run()
287 NVolSetErrors(NTFS_SB(vi->i_sb)); in __ntfs_bitmap_set_bits_in_run()