Merge branch 'maint' into next

Conflicts:
	misc/mke2fs.c
bitmap-optimize
Theodore Ts'o 2009-11-16 00:30:57 -05:00
commit 4486af5b4c
7 changed files with 87 additions and 5 deletions

2
debian/control.in vendored
View File

@ -229,7 +229,7 @@ Description: ext2/ext3/ext4 file system libraries - headers and static libraries
Package: e2fsprogs
Essential: yes
ifdef(`UTIL_LINUX_NG',
``Pre-Depends: ${shlibs:Depends}, ${misc:Depends}, util-linux (<< 2.15~rc1-1)
``Pre-Depends: ${shlibs:Depends}, ${misc:Depends}, util-linux (>= 2.15~rc1-1)
'',
``Pre-Depends: ${shlibs:Depends}, ${misc:Depends}
'')dnl

View File

@ -253,8 +253,16 @@ static int is_swap_device(const char *file)
if (!(f = fopen("/proc/swaps", "r")))
return 0;
/* Skip the first line */
if (fgets(buf, sizeof(buf), f))
if (!fgets(buf, sizeof(buf), f))
goto leave;
if (*buf && strncmp(buf, "Filename\t", 9))
/* Linux <=2.6.19 contained a bug in the /proc/swaps
* code where the header would not be displayed
*/
goto valid_first_line;
while (fgets(buf, sizeof(buf), f)) {
valid_first_line:
if ((cp = strchr(buf, ' ')) != NULL)
*cp = 0;
if ((cp = strchr(buf, '\t')) != NULL)
@ -272,6 +280,8 @@ static int is_swap_device(const char *file)
}
#endif /* __GNU__ */
}
leave:
fclose(f);
return ret;
}

View File

@ -73,9 +73,19 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
sb->s_kbytes_written = ext2fs_swab64(sb->s_kbytes_written);
for (i=0; i < 4; i++)
sb->s_hash_seed[i] = ext2fs_swab32(sb->s_hash_seed[i]);
/* if journal backup is for a valid extent-based journal... */
if (!ext2fs_extent_header_verify(sb->s_jnl_blocks,
sizeof(sb->s_jnl_blocks))) {
/* ... swap only the journal i_size */
sb->s_jnl_blocks[16] = ext2fs_swab32(sb->s_jnl_blocks[16]);
/* and the extent data is not swapped on read */
return;
}
/* direct/indirect journal: swap it all */
for (i=0; i < 17; i++)
sb->s_jnl_blocks[i] = ext2fs_swab32(sb->s_jnl_blocks[i]);
}
void ext2fs_swap_group_desc2(ext2_filsys fs, struct ext2_group_desc *gdp)

View File

@ -71,6 +71,7 @@ int ss_create_invocation(subsystem_name, version_string, info_ptr,
*(new_table->rqt_tables+1) = (ss_request_table *) NULL;
new_table->readline_handle = 0;
new_table->readline_shutdown = 0;
new_table->readline = 0;
new_table->add_history = 0;
new_table->redisplay = 0;

View File

@ -45,6 +45,9 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
.I journal-options
]
[
.B \-K
]
[
.B \-N
.I number-of-inodes
]
@ -366,6 +369,10 @@ and may be no more than 102,400 filesystem blocks.
@JDEV@.BR size " or " device
@JDEV@options can be given for a filesystem.
.TP
.BI \-K
Keep, do not attempt to discard blocks at mkfs time (discarding blocks initially
is useful on solid state devices and sparse / thin-provisioned storage).
.TP
.BI \-l " filename"
Read the bad blocks list from
.IR filename .

View File

@ -80,6 +80,7 @@ int cflag;
int verbose;
int quiet;
int super_only;
int discard = 1;
int force;
int noaction;
int journal_size;
@ -112,7 +113,7 @@ static void usage(void)
"\t[-g blocks-per-group] [-L volume-label] "
"[-M last-mounted-directory]\n\t[-O feature[,...]] "
"[-r fs-revision] [-E extended-option[,...]]\n"
"\t[-T fs-type] [-U UUID] [-jnqvFSV] device [blocks-count]\n"),
"\t[-T fs-type] [-U UUID] [-jnqvFKSV] device [blocks-count]\n"),
program_name);
exit(1);
}
@ -1150,7 +1151,7 @@ static void PRS(int argc, char *argv[])
}
while ((c = getopt (argc, argv,
"b:cf:g:G:i:jl:m:no:qr:s:t:vE:FI:J:L:M:N:O:R:ST:U:V")) != EOF) {
"b:cf:g:G:i:jl:m:no:qr:s:t:vE:FI:J:KL:M:N:O:R:ST:U:V")) != EOF) {
switch (c) {
case 'b':
blocksize = strtol(optarg, &tmp, 0);
@ -1229,6 +1230,9 @@ static void PRS(int argc, char *argv[])
case 'J':
parse_journal_opts(optarg);
break;
case 'K':
discard = 0;
break;
case 'j':
if (!journal_size)
journal_size = -1;
@ -1854,6 +1858,48 @@ static int mke2fs_setup_tdb(const char *name, io_manager *io_ptr)
return retval;
}
#ifdef __linux__
#ifndef BLKDISCARD
#define BLKDISCARD _IO(0x12,119)
#endif
static void mke2fs_discard_blocks(ext2_filsys fs)
{
int fd;
int ret;
int blocksize;
__u64 blocks;
__uint64_t range[2];
blocks = ext2fs_blocks_count(fs->super);
blocksize = EXT2_BLOCK_SIZE(fs->super);
range[0] = 0;
range[1] = blocks * blocksize;
fd = open64(fs->device_name, O_RDONLY);
/*
* We don't care about whether the ioctl succeeds; it's only an
* optmization for SSDs or sparse storage.
*/
if (fd > 0) {
ret = ioctl(fd, BLKDISCARD, &range);
if (verbose) {
printf(_("Calling BLKDISCARD from %llu to %llu "),
range[0], range[1]);
if (ret)
printf(_("failed.\n"));
else
printf(_("succeeded.\n"));
}
close(fd);
}
}
#else
#define mke2fs_discard_blocks(fs)
#endif
int main (int argc, char *argv[])
{
errcode_t retval = 0;
@ -1911,6 +1957,10 @@ int main (int argc, char *argv[])
exit(1);
}
/* Can't undo discard ... */
if (discard && (io_ptr != undo_io_manager))
mke2fs_discard_blocks(fs);
sprintf(tdb_string, "tdb_data_size=%d", fs->blocksize <= 4096 ?
32768 : fs->blocksize * 8);
io_channel_set_options(fs->io, tdb_string);

View File

@ -1880,6 +1880,10 @@ static errcode_t fix_sb_journal_backup(ext2_filsys fs)
if (!(fs->super->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL))
return 0;
/* External journal? Nothing to do. */
if (fs->super->s_journal_dev && !fs->super->s_journal_inum)
return 0;
retval = ext2fs_read_inode(fs, fs->super->s_journal_inum, &inode);
if (retval)
return retval;