⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcnalloc.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
							"0x%llx.",							(unsigned long long)							(lcn + bmp_pos));				rl2 = ntfs_malloc_nofs(rlsize + (int)PAGE_SIZE);				if (unlikely(!rl2)) {					err = -ENOMEM;					ntfs_error(vol->sb, "Failed to "							"allocate memory.");					goto out;				}				memcpy(rl2, rl, rlsize);				ntfs_free(rl);				rl = rl2;				rlsize += PAGE_SIZE;				ntfs_debug("Reallocated memory, rlsize 0x%x.",						rlsize);			}			/* Allocate the bitmap bit. */			*byte |= bit;			/* We need to write this bitmap page to disk. */			need_writeback = 1;			ntfs_debug("*byte 0x%x, need_writeback is set.",					(unsigned int)*byte);			/*			 * Coalesce with previous run if adjacent LCNs.			 * Otherwise, append a new run.			 */			ntfs_debug("Adding run (lcn 0x%llx, len 0x%llx), "					"prev_lcn 0x%llx, lcn 0x%llx, "					"bmp_pos 0x%llx, prev_run_len 0x%llx, "					"rlpos %i.",					(unsigned long long)(lcn + bmp_pos),					1ULL, (unsigned long long)prev_lcn,					(unsigned long long)lcn,					(unsigned long long)bmp_pos,					(unsigned long long)prev_run_len,					rlpos);			if (prev_lcn == lcn + bmp_pos - prev_run_len && rlpos) {				ntfs_debug("Coalescing to run (lcn 0x%llx, "						"len 0x%llx).",						(unsigned long long)						rl[rlpos - 1].lcn,						(unsigned long long)						rl[rlpos - 1].length);				rl[rlpos - 1].length = ++prev_run_len;				ntfs_debug("Run now (lcn 0x%llx, len 0x%llx), "						"prev_run_len 0x%llx.",						(unsigned long long)						rl[rlpos - 1].lcn,						(unsigned long long)						rl[rlpos - 1].length,						(unsigned long long)						prev_run_len);			} else {				if (likely(rlpos)) {					ntfs_debug("Adding new run, (previous "							"run lcn 0x%llx, "							"len 0x%llx).",							(unsigned long long)							rl[rlpos - 1].lcn,							(unsigned long long)							rl[rlpos - 1].length);					rl[rlpos].vcn = rl[rlpos - 1].vcn +							prev_run_len;				} else {					ntfs_debug("Adding new run, is first "							"run.");					rl[rlpos].vcn = start_vcn;				}				rl[rlpos].lcn = prev_lcn = lcn + bmp_pos;				rl[rlpos].length = prev_run_len = 1;				rlpos++;			}			/* Done? */			if (!--clusters) {				LCN tc;				/*				 * Update the current zone position.  Positions				 * of already scanned zones have been updated				 * during the respective zone switches.				 */				tc = lcn + bmp_pos + 1;				ntfs_debug("Done. Updating current zone "						"position, tc 0x%llx, "						"search_zone %i.",						(unsigned long long)tc,						search_zone);				switch (search_zone) {				case 1:					ntfs_debug("Before checks, "							"vol->mft_zone_pos "							"0x%llx.",							(unsigned long long)							vol->mft_zone_pos);					if (tc >= vol->mft_zone_end) {						vol->mft_zone_pos =								vol->mft_lcn;						if (!vol->mft_zone_end)							vol->mft_zone_pos = 0;					} else if ((bmp_initial_pos >=							vol->mft_zone_pos ||							tc > vol->mft_zone_pos)							&& tc >= vol->mft_lcn)						vol->mft_zone_pos = tc;					ntfs_debug("After checks, "							"vol->mft_zone_pos "							"0x%llx.",							(unsigned long long)							vol->mft_zone_pos);					break;				case 2:					ntfs_debug("Before checks, "							"vol->data1_zone_pos "							"0x%llx.",							(unsigned long long)							vol->data1_zone_pos);					if (tc >= vol->nr_clusters)						vol->data1_zone_pos =							     vol->mft_zone_end;					else if ((bmp_initial_pos >=						    vol->data1_zone_pos ||						    tc > vol->data1_zone_pos)						    && tc >= vol->mft_zone_end)						vol->data1_zone_pos = tc;					ntfs_debug("After checks, "							"vol->data1_zone_pos "							"0x%llx.",							(unsigned long long)							vol->data1_zone_pos);					break;				case 4:					ntfs_debug("Before checks, "							"vol->data2_zone_pos "							"0x%llx.",							(unsigned long long)							vol->data2_zone_pos);					if (tc >= vol->mft_zone_start)						vol->data2_zone_pos = 0;					else if (bmp_initial_pos >=						      vol->data2_zone_pos ||						      tc > vol->data2_zone_pos)						vol->data2_zone_pos = tc;					ntfs_debug("After checks, "							"vol->data2_zone_pos "							"0x%llx.",							(unsigned long long)							vol->data2_zone_pos);					break;				default:					BUG();				}				ntfs_debug("Finished.  Going to out.");				goto out;			}			lcn++;		}		bmp_pos += buf_size;		ntfs_debug("After inner while loop: buf_size 0x%x, lcn "				"0x%llx, bmp_pos 0x%llx, need_writeback %i.",				buf_size, (unsigned long long)lcn,				(unsigned long long)bmp_pos, need_writeback);		if (bmp_pos < zone_end) {			ntfs_debug("Continuing outer while loop, "					"bmp_pos 0x%llx, zone_end 0x%llx.",					(unsigned long long)bmp_pos,					(unsigned long long)zone_end);			continue;		}zone_pass_done:	/* Finished with the current zone pass. */		ntfs_debug("At zone_pass_done, pass %i.", pass);		if (pass == 1) {			/*			 * Now do pass 2, scanning the first part of the zone			 * we omitted in pass 1.			 */			pass = 2;			zone_end = zone_start;			switch (search_zone) {			case 1: /* mft_zone */				zone_start = vol->mft_zone_start;				break;			case 2: /* data1_zone */				zone_start = vol->mft_zone_end;				break;			case 4: /* data2_zone */				zone_start = 0;				break;			default:				BUG();			}			/* Sanity check. */			if (zone_end < zone_start)				zone_end = zone_start;			bmp_pos = zone_start;			ntfs_debug("Continuing outer while loop, pass 2, "					"zone_start 0x%llx, zone_end 0x%llx, "					"bmp_pos 0x%llx.",					(unsigned long long)zone_start,					(unsigned long long)zone_end,					(unsigned long long)bmp_pos);			continue;		} /* pass == 2 */done_zones_check:		ntfs_debug("At done_zones_check, search_zone %i, done_zones "				"before 0x%x, done_zones after 0x%x.",				search_zone, done_zones,				done_zones | search_zone);		done_zones |= search_zone;		if (done_zones < 7) {			ntfs_debug("Switching zone.");			/* Now switch to the next zone we haven't done yet. */			pass = 1;			switch (search_zone) {			case 1:				ntfs_debug("Switching from mft zone to data1 "						"zone.");				/* Update mft zone position. */				if (rlpos) {					LCN tc;					ntfs_debug("Before checks, "							"vol->mft_zone_pos "							"0x%llx.",							(unsigned long long)							vol->mft_zone_pos);					tc = rl[rlpos - 1].lcn +							rl[rlpos - 1].length;					if (tc >= vol->mft_zone_end) {						vol->mft_zone_pos =								vol->mft_lcn;						if (!vol->mft_zone_end)							vol->mft_zone_pos = 0;					} else if ((bmp_initial_pos >=							vol->mft_zone_pos ||							tc > vol->mft_zone_pos)							&& tc >= vol->mft_lcn)						vol->mft_zone_pos = tc;					ntfs_debug("After checks, "							"vol->mft_zone_pos "							"0x%llx.",							(unsigned long long)							vol->mft_zone_pos);				}				/* Switch from mft zone to data1 zone. */switch_to_data1_zone:		search_zone = 2;				zone_start = bmp_initial_pos =						vol->data1_zone_pos;				zone_end = vol->nr_clusters;				if (zone_start == vol->mft_zone_end)					pass = 2;				if (zone_start >= zone_end) {					vol->data1_zone_pos = zone_start =							vol->mft_zone_end;					pass = 2;				}				break;			case 2:				ntfs_debug("Switching from data1 zone to "						"data2 zone.");				/* Update data1 zone position. */				if (rlpos) {					LCN tc;					ntfs_debug("Before checks, "							"vol->data1_zone_pos "							"0x%llx.",							(unsigned long long)							vol->data1_zone_pos);					tc = rl[rlpos - 1].lcn +							rl[rlpos - 1].length;					if (tc >= vol->nr_clusters)						vol->data1_zone_pos =							     vol->mft_zone_end;					else if ((bmp_initial_pos >=						    vol->data1_zone_pos ||						    tc > vol->data1_zone_pos)						    && tc >= vol->mft_zone_end)						vol->data1_zone_pos = tc;					ntfs_debug("After checks, "							"vol->data1_zone_pos "							"0x%llx.",							(unsigned long long)							vol->data1_zone_pos);				}				/* Switch from data1 zone to data2 zone. */				search_zone = 4;				zone_start = bmp_initial_pos =						vol->data2_zone_pos;				zone_end = vol->mft_zone_start;				if (!zone_start)					pass = 2;				if (zone_start >= zone_end) {					vol->data2_zone_pos = zone_start =							bmp_initial_pos = 0;					pass = 2;				}				break;			case 4:				ntfs_debug("Switching from data2 zone to "						"data1 zone.");				/* Update data2 zone position. */				if (rlpos) {					LCN tc;					ntfs_debug("Before checks, "							"vol->data2_zone_pos "							"0x%llx.",							(unsigned long long)							vol->data2_zone_pos);					tc = rl[rlpos - 1].lcn +							rl[rlpos - 1].length;					if (tc >= vol->mft_zone_start)						vol->data2_zone_pos = 0;					else if (bmp_initial_pos >=						      vol->data2_zone_pos ||						      tc > vol->data2_zone_pos)						vol->data2_zone_pos = tc;					ntfs_debug("After checks, "							"vol->data2_zone_pos "							"0x%llx.",							(unsigned long long)							vol->data2_zone_pos);				}				/* Switch from data2 zone to data1 zone. */				goto switch_to_data1_zone;			default:				BUG();			}			ntfs_debug("After zone switch, search_zone %i, "					"pass %i, bmp_initial_pos 0x%llx, "					"zone_start 0x%llx, zone_end 0x%llx.",					search_zone, pass,					(unsigned long long)bmp_initial_pos,					(unsigned long long)zone_start,					(unsigned long long)zone_end);			bmp_pos = zone_start;			if (zone_start == zone_end) {				ntfs_debug("Empty zone, going to "						"done_zones_check.");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -