Ejemplo n.º 1
0
static ssize_t lssu_print_suinfo(struct nilfs *nilfs, uint64_t segnum,
				 ssize_t nsi, uint64_t protseq)
{
	struct tm tm;
	time_t t;
	char timebuf[LSSU_BUFSIZE];
	ssize_t i, n = 0, ret;
	int ratio;
	int protected;
	size_t nliveblks;

	for (i = 0; i < nsi; i++, segnum++) {
		if (!all && nilfs_suinfo_clean(&suinfos[i]))
			continue;

		t = (time_t)suinfos[i].sui_lastmod;
		if (t != 0) {
			localtime_r(&t, &tm);
			strftime(timebuf, LSSU_BUFSIZE, "%F %T", &tm);
		} else
			snprintf(timebuf, LSSU_BUFSIZE,
				 "---------- --:--:--");

		switch (disp_mode) {
		case LSSU_MODE_NORMAL:
			printf(lssu_format[disp_mode].body,
			       (unsigned long long)segnum,
			       timebuf,
			       nilfs_suinfo_active(&suinfos[i]) ? 'a' : '-',
			       nilfs_suinfo_dirty(&suinfos[i]) ? 'd' : '-',
			       nilfs_suinfo_error(&suinfos[i]) ? 'e' : '-',
			       suinfos[i].sui_nblocks);
			break;
		case LSSU_MODE_LATEST_USAGE:
			nliveblks = 0;
			ratio = 0;
			protected = (t >= prottime && t <= now);

			if (!nilfs_suinfo_dirty(&suinfos[i]) ||
			    nilfs_suinfo_error(&suinfos[i]))
				goto skip_scan;

			ret = lssu_get_latest_usage(nilfs, segnum, protseq,
						    protcno);
			if (ret >= 0) {
				nliveblks = ret;
				ratio = (ret * 100 + 99) / blocks_per_segment;
			} else if (likely(ret == -2)) {
				nliveblks = suinfos[i].sui_nblocks;
				ratio = 100;
				protected = 1;
			} else {
Ejemplo n.º 2
0
static ssize_t lssu_print_suinfo(__u64 segnum, ssize_t nsi, int all)
{
	struct tm tm;
	time_t t;
	char timebuf[LSSU_BUFSIZE];
	ssize_t i, n = 0;

	for (i = 0; i < nsi; i++, segnum++) {
		if (all || !nilfs_suinfo_clean(&suinfos[i])) {
			t = (time_t)suinfos[i].sui_lastmod;
			if (t != 0) {
				localtime_r(&t, &tm);
				strftime(timebuf, LSSU_BUFSIZE, "%F %T", &tm);
			} else
				snprintf(timebuf, LSSU_BUFSIZE,
					 "---------- --:--:--");

			printf("%20llu  %s  %c%c%c  %10u\n",
			       (unsigned long long)segnum,
			       timebuf,
			       nilfs_suinfo_active(&suinfos[i]) ? 'a' : '-',
			       nilfs_suinfo_dirty(&suinfos[i]) ? 'd' : '-',
			       nilfs_suinfo_error(&suinfos[i]) ? 'e' : '-',
			       suinfos[i].sui_nblocks);
			n++;
		}
	}
	return n;
}
Ejemplo n.º 3
0
static ssize_t lssu_print_suinfo(struct nilfs *nilfs, __u64 segnum,
				 ssize_t nsi, __u64 protseq,
				 unsigned long* bitmap)
{
	ssize_t i, n = 0;
	int all = 1;

	for (i = 0; i < nsi; i++, segnum++) {
		if (!all && nilfs_suinfo_clean(&suinfos[i]))
			continue;

			log_mesg(3, 0, 0, fs_opt.debug, "%s: seg %llu, %c %c %c , %i\n",
			       __FILE__, (unsigned long long)segnum,
			       nilfs_suinfo_active(&suinfos[i]) ? 'a' : '-',
			       nilfs_suinfo_dirty(&suinfos[i]) ? 'd' : '-',
			       nilfs_suinfo_error(&suinfos[i]) ? 'e' : '-',
			       suinfos[i].sui_nblocks);
		if  (nilfs_suinfo_active(&suinfos[i]) || nilfs_suinfo_dirty(&suinfos[i])){
		    set_bitmap(bitmap, (unsigned long long)segnum,  suinfos[i].sui_nblocks);
		}
		n++;
	}
	return n;
}