mirror of https://github.com/vitalif/e2fsprogs
commit
827f45243a
|
@ -15,6 +15,7 @@ DVI=texi2dvi
|
|||
DVIPS=dvips -o "$@"
|
||||
INFO=@MAKEINFO@
|
||||
HTML=texi2html -split_chapter
|
||||
PS2PDF=ps2pdf
|
||||
|
||||
all:: libext2fs.info libext2fs.dvi
|
||||
|
||||
|
@ -40,6 +41,14 @@ libext2fs.dvi: $(srcdir)/libext2fs.texinfo
|
|||
$(E) " TEXI2DVI $@"
|
||||
-$(Q) $(DVI) $(srcdir)/libext2fs.texinfo
|
||||
|
||||
libext2fs.ps: libext2fs.dvi
|
||||
$(E) " DVIPS $@"
|
||||
-$(Q) $(DVIPS) libext2fs.dvi
|
||||
|
||||
libext2fs.pdf: libext2fs.ps
|
||||
$(E) " PS2PDF $@"
|
||||
-$(Q) $(PS2PDF) libext2fs.ps
|
||||
|
||||
libext2fs_abt.html: $(srcdir)/libext2fs.texinfo
|
||||
$(E) " TEXI2HTML $@"
|
||||
-$(Q) $(HTML) $(srcdir)/libext2fs.texinfo
|
||||
|
@ -59,7 +68,7 @@ clean-all:: clean-tex clean-backup clean-final clean-tarfiles clean-html
|
|||
|
||||
.PHONY: clean-final
|
||||
clean-final::
|
||||
$(RM) -f *.ps *.info *.info-? *.html
|
||||
$(RM) -f *.ps *.info *.info-? *.html *.pdf
|
||||
|
||||
.PHONY: clean-tex
|
||||
clean-tex::
|
||||
|
|
|
@ -104,8 +104,6 @@ by the Foundation.
|
|||
|
||||
This manual documents the EXT2FS Library, version 1.42.7.
|
||||
|
||||
@end ifinfo
|
||||
|
||||
@menu
|
||||
* Introduction to the EXT2FS Library::
|
||||
* EXT2FS Library Functions::
|
||||
|
@ -113,6 +111,8 @@ This manual documents the EXT2FS Library, version 1.42.7.
|
|||
* Function Index::
|
||||
@end menu
|
||||
|
||||
@end ifinfo
|
||||
|
||||
@c ----------------------------------------------------------------------
|
||||
|
||||
@node Introduction to the EXT2FS Library, EXT2FS Library Functions, Top, Top
|
||||
|
|
|
@ -317,7 +317,8 @@ void check_resize_inode(e2fsck_t ctx)
|
|||
struct problem_context pctx;
|
||||
int i, gdt_off, ind_off;
|
||||
dgrp_t j;
|
||||
blk64_t blk, pblk, expect;
|
||||
blk64_t blk, pblk;
|
||||
blk_t expect; /* for resize inode, which is 32-bit only */
|
||||
__u32 *dind_buf = 0, *ind_buf;
|
||||
errcode_t retval;
|
||||
|
||||
|
@ -927,8 +928,7 @@ int check_backup_super_block(e2fsck_t ctx)
|
|||
if (!ext2fs_bg_has_super(fs, g))
|
||||
continue;
|
||||
|
||||
sb = fs->super->s_first_data_block +
|
||||
(g * fs->super->s_blocks_per_group);
|
||||
sb = ext2fs_group_first_block2(fs, g);
|
||||
|
||||
retval = io_channel_read_blk(fs->io, sb, -SUPERBLOCK_SIZE,
|
||||
buf);
|
||||
|
|
|
@ -59,12 +59,34 @@ compile_et: $(DEP_SUBSTITUTE) $(srcdir)/compile_et.sh.in
|
|||
$(Q) $(SUBSTITUTE) $(srcdir)/compile_et.sh.in compile_et
|
||||
$(Q) $(CHMOD) +x compile_et
|
||||
|
||||
DVI=texi2dvi
|
||||
DVIPS=dvips -o "$@"
|
||||
INFO=@MAKEINFO@
|
||||
HTML=texi2html -split_chapter
|
||||
PS2PDF=ps2pdf
|
||||
|
||||
com_err.ps : com_err.dvi
|
||||
com_err.dvi: com_err.texinfo
|
||||
|
||||
com_err.info: $(srcdir)/com_err.texinfo
|
||||
$(E) " MAKEINFO $@"
|
||||
-$(Q) $(INFO) $(srcdir)/com_err.texinfo
|
||||
|
||||
com_err.dvi: $(srcdir)/com_err.texinfo
|
||||
$(E) " TEXI2DVI $@"
|
||||
-$(Q) $(DVI) $(srcdir)/com_err.texinfo
|
||||
|
||||
com_err.ps: com_err.dvi
|
||||
$(E) " DVIPS $@"
|
||||
-$(Q) $(DVIPS) com_err.dvi
|
||||
|
||||
com_err.pdf: com_err.ps
|
||||
$(E) " PS2PDF $@"
|
||||
-$(Q) $(PS2PDF) com_err.ps
|
||||
|
||||
com_err_abt.html: $(srcdir)/com_err.texinfo
|
||||
$(E) " TEXI2HTML $@"
|
||||
-$(Q) texi2html -split_chapter $(srcdir)/com_err.texinfo
|
||||
-$(Q) $(HTML) $(srcdir)/com_err.texinfo
|
||||
-$(Q) if test -d com_err ; then \
|
||||
mv com_err/* . ; rmdir com_err ; \
|
||||
fi
|
||||
|
@ -133,7 +155,9 @@ check:: compile_et
|
|||
clean::
|
||||
$(RM) -f compile_et libcom_err.a libcom_err_p.a com_err.info
|
||||
$(RM) -f $(OBJS) profiled/*
|
||||
$(RM) -f *~ \#* *.bak *.otl *.aux *.toc *.PS *.dvi *.ps TAGS *.ln *.html
|
||||
$(RM) -f *~ \#* *.bak *.otl *.aux *.toc *.PS *.dvi *.ps TAGS *.ln \
|
||||
*.html *.cp *.fn *.fns *.ky *.log *.pc *.pg *.toc *.tp *.vr \
|
||||
*.pdf
|
||||
$(RM) -f ../libcom_err.a ../libcom_err_p.a
|
||||
|
||||
mostlyclean:: clean
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
@c Software Foundation, and is under different copyright restrictions
|
||||
@c from the rest of this package.)
|
||||
|
||||
@setfilename com_err
|
||||
@setfilename com_err.info
|
||||
@settitle A Common Error Description Library for UNIX
|
||||
|
||||
@ifinfo
|
||||
|
@ -24,14 +24,10 @@
|
|||
@end direntry
|
||||
@end ifinfo
|
||||
|
||||
@iftex
|
||||
@tolerance 10000
|
||||
@c smallbook
|
||||
|
||||
@c Mutate section headers...
|
||||
@begingroup
|
||||
@catcode#=6
|
||||
@gdef@secheading#1#2#3{@secheadingi {#3@enspace #1}}
|
||||
@endgroup
|
||||
@iftex
|
||||
@finalout
|
||||
@end iftex
|
||||
|
||||
@ifinfo
|
||||
|
@ -61,6 +57,7 @@ notice identical to this one except for the removal of this paragraph
|
|||
(this paragraph not being relevant to the printed manual).
|
||||
|
||||
@end ignore
|
||||
@end ifinfo
|
||||
|
||||
@setchapternewpage odd
|
||||
|
||||
|
@ -114,7 +111,7 @@ from the remainder of this package.
|
|||
|
||||
@end titlepage
|
||||
|
||||
|
||||
@ifinfo
|
||||
@node Top, Why com_err?, (dir), (dir)
|
||||
|
||||
@top A Common Error Description Library for UNIX
|
||||
|
@ -133,12 +130,11 @@ This manual documents the com_err library.
|
|||
* Acknowledgements::
|
||||
@end menu
|
||||
|
||||
@page
|
||||
@end ifinfo
|
||||
|
||||
@page
|
||||
|
||||
@node Why com_err?, Error codes, Top, Top
|
||||
@section Why com_err?
|
||||
@chapter Why com_err?
|
||||
|
||||
In building application software packages, a programmer often has to
|
||||
deal with a number of libraries, each of which can use a different
|
||||
|
@ -174,7 +170,7 @@ of the form @samp{unknown code foo 32}, where @samp{foo} would be the name
|
|||
of the table.
|
||||
|
||||
@node Error codes, Error table source file, Why com_err?, Top
|
||||
@section Error codes
|
||||
@chapter Error codes
|
||||
|
||||
Error codes themselves are 32 bit (signed) integers, of which the high
|
||||
order 24 bits are an identifier of which error table the error code is
|
||||
|
@ -203,7 +199,7 @@ much other software that assumes an ANSI-C environment base) without
|
|||
significant effort.
|
||||
|
||||
@node Error table source file, The error-table compiler, Error codes, Top
|
||||
@section Error table source file
|
||||
@chapter Error table source file
|
||||
|
||||
The error table source file begins with the declaration of the table name,
|
||||
as
|
||||
|
@ -241,7 +237,7 @@ error table might be:
|
|||
@end example
|
||||
|
||||
@node The error-table compiler, Run-time support routines, Error table source file, Top
|
||||
@section The error-table compiler
|
||||
@chapter The error-table compiler
|
||||
|
||||
The error table compiler is named @code{compile_et}. It takes one
|
||||
argument, the pathname of a file (ending in @samp{.et}, e.g.,
|
||||
|
@ -255,7 +251,7 @@ codes defined; the object module generated from the C code may be linked in
|
|||
to a program which wishes to use the printed forms of the error codes.
|
||||
|
||||
@node Run-time support routines, Coding Conventions, The error-table compiler, Top
|
||||
@section Run-time support routines
|
||||
@chapter Run-time support routines
|
||||
|
||||
Any source file which uses the routines supplied with or produced by the
|
||||
com_err package should include the header file @file{<com_err.h>}. It
|
||||
|
@ -306,9 +302,7 @@ left to circumstances which render @code{com_err} (below) unusable.
|
|||
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun
|
||||
void com_err (const char *@var{whoami}, long @var{error_code},
|
||||
const char *@var{format}, ...);
|
||||
@deftypefun void com_err (const char *@var{whoami}, long @var{error_code}, const char *@var{format}, ...);
|
||||
|
||||
This routine provides an alternate way to print error messages to
|
||||
standard error; it allows the error message to be passed in as a
|
||||
|
@ -321,8 +315,7 @@ printed. @var{format} may not be omitted.
|
|||
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun
|
||||
void com_err_va (const char *@var{whoami}, long @var{error_code}, const char *@var{format}, va_list @var{args});
|
||||
@deftypefun void com_err_va (const char *@var{whoami}, long @var{error_code}, const char *@var{format}, va_list @var{args});
|
||||
|
||||
This routine provides an interface, equivalent to @code{com_err} above,
|
||||
which may be used by higher-level variadic functions (functions which
|
||||
|
@ -330,7 +323,7 @@ accept variable numbers of arguments).
|
|||
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void (*set_com_err_hook (void (*@var{proc}) (const char *@var{whoami}, long @var{error_code}, va_list @var{args}))) (const char *@var{whoami}, long @var{error_code}, va_list @var{args});
|
||||
@deftypefun void *set_com_err_hook (void (*@var{proc}) (const char *@var{whoami}, long @var{error_code}, va_list @var{args}) (const char *@var{whoami}, long @var{error_code}, va_list @var{args}));
|
||||
|
||||
@deftypefunx void reset_com_err_hook ();
|
||||
|
||||
|
@ -390,7 +383,7 @@ the ANSI C library).
|
|||
@end deftypefun
|
||||
|
||||
@node Coding Conventions, Building and Installation, Run-time support routines, Top
|
||||
@section Coding Conventions
|
||||
@chapter Coding Conventions
|
||||
|
||||
The following conventions are just some general stylistic conventions
|
||||
to follow when writing robust libraries and programs. Conventions
|
||||
|
@ -501,7 +494,7 @@ error:
|
|||
@end example
|
||||
|
||||
@node Building and Installation, Bug Reports, Coding Conventions, Top
|
||||
@section Building and Installation
|
||||
@chapter Building and Installation
|
||||
|
||||
The distribution of this package will probably be done as a compressed
|
||||
``tar''-format file available via anonymous FTP from SIPB.MIT.EDU.
|
||||
|
@ -514,7 +507,7 @@ installed for use; @samp{com_err.3} and @samp{compile_et.1} can also be
|
|||
installed as manual pages.
|
||||
|
||||
@node Bug Reports, Acknowledgements, Building and Installation, Top
|
||||
@section Bug Reports
|
||||
@chapter Bug Reports
|
||||
|
||||
The principal author of this library is: Ken
|
||||
Raeburn, @t{raeburn@@MIT.EDU}.
|
||||
|
@ -524,7 +517,7 @@ Ts'o, and so bugs and comments should be sent to @t{tytso@@thunk.org}.
|
|||
|
||||
|
||||
@node Acknowledgements, , Bug Reports, Top
|
||||
@section Acknowledgements
|
||||
@chapter Acknowledgements
|
||||
|
||||
I would like to thank: Bill Sommerfeld, for his help with some of this
|
||||
documentation, and catching some of the bugs the first time around;
|
||||
|
|
8371
lib/et/texinfo.tex
8371
lib/et/texinfo.tex
File diff suppressed because it is too large
Load Diff
|
@ -40,8 +40,7 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
|
|||
!(ext2fs_bg_flags_test(fs, group, EXT2_BG_BLOCK_UNINIT)))
|
||||
return;
|
||||
|
||||
blk = (group * fs->super->s_blocks_per_group) +
|
||||
fs->super->s_first_data_block;
|
||||
blk = ext2fs_group_first_block2(fs, group);
|
||||
|
||||
ext2fs_super_and_bgd_loc2(fs, group, &super_blk,
|
||||
&old_desc_blk, &new_desc_blk, 0);
|
||||
|
@ -55,8 +54,7 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
|
|||
for (i=0; i < fs->super->s_blocks_per_group; i++, blk++)
|
||||
ext2fs_fast_unmark_block_bitmap2(map, blk);
|
||||
|
||||
blk = (group * fs->super->s_blocks_per_group) +
|
||||
fs->super->s_first_data_block;
|
||||
blk = ext2fs_group_first_block2(fs, group);
|
||||
for (i=0; i < fs->super->s_blocks_per_group; i++, blk++) {
|
||||
if ((blk == super_blk) ||
|
||||
(old_desc_blk && old_desc_blocks &&
|
||||
|
|
|
@ -67,10 +67,11 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs,
|
|||
if (old_desc_blk) {
|
||||
if (fs->super->s_reserved_gdt_blocks && fs->block_map == bmap)
|
||||
ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
|
||||
for (j=0; j < old_desc_blocks; j++)
|
||||
if (old_desc_blk + j < ext2fs_blocks_count(fs->super))
|
||||
ext2fs_mark_block_bitmap2(bmap,
|
||||
old_desc_blk + j);
|
||||
num_blocks = old_desc_blocks;
|
||||
if (old_desc_blk + num_blocks >= ext2fs_blocks_count(fs->super))
|
||||
num_blocks = ext2fs_blocks_count(fs->super) -
|
||||
old_desc_blk;
|
||||
ext2fs_mark_block_bitmap_range2(bmap, old_desc_blk, num_blocks);
|
||||
}
|
||||
if (new_desc_blk)
|
||||
ext2fs_mark_block_bitmap2(bmap, new_desc_blk);
|
||||
|
|
|
@ -950,8 +950,7 @@ errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle)
|
|||
|
||||
if (log_flex)
|
||||
group = group & ~((1 << (log_flex)) - 1);
|
||||
goal_blk = (group * handle->fs->super->s_blocks_per_group) +
|
||||
handle->fs->super->s_first_data_block;
|
||||
goal_blk = ext2fs_group_first_block2(handle->fs, group);
|
||||
}
|
||||
retval = ext2fs_alloc_block2(handle->fs, goal_blk, block_buf,
|
||||
&new_node_pblk);
|
||||
|
|
|
@ -358,9 +358,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
|
|||
ext2fs_bg_free_blocks_count(fs, group))
|
||||
group = i;
|
||||
|
||||
es.goal = (fs->super->s_blocks_per_group * group) +
|
||||
fs->super->s_first_data_block;
|
||||
|
||||
es.goal = ext2fs_group_first_block2(fs, group);
|
||||
retval = ext2fs_block_iterate3(fs, journal_ino, BLOCK_FLAG_APPEND,
|
||||
0, mkjournal_proc, &es);
|
||||
if (es.err) {
|
||||
|
|
|
@ -16,7 +16,8 @@ PROGS= resize2fs
|
|||
TEST_PROGS= test_extent
|
||||
MANPAGES= resize2fs.8
|
||||
|
||||
RESIZE_OBJS= extent.o resize2fs.o main.o online.o sim_progress.o
|
||||
RESIZE_OBJS= extent.o resize2fs.o main.o online.o resource_track.o \
|
||||
sim_progress.o
|
||||
|
||||
TEST_EXTENT_OBJS= extent.o test_extent.o
|
||||
|
||||
|
@ -24,6 +25,7 @@ SRCS= $(srcdir)/extent.c \
|
|||
$(srcdir)/resize2fs.c \
|
||||
$(srcdir)/main.c \
|
||||
$(srcdir)/online.c \
|
||||
$(srcdir)/resource_track.c \
|
||||
$(srcdir)/sim_progress.c
|
||||
|
||||
LIBS= $(LIBE2P) $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBINTL)
|
||||
|
@ -144,35 +146,48 @@ source_tar_file: $(top_srcdir)/.exclude-file
|
|||
# Makefile dependencies follow. This must be the last section in
|
||||
# the Makefile.in file
|
||||
#
|
||||
extent.o: $(srcdir)/extent.c $(srcdir)/resize2fs.h \
|
||||
extent.o: $(srcdir)/extent.c $(top_builddir)/lib/config.h \
|
||||
$(top_builddir)/lib/dirpaths.h $(srcdir)/resize2fs.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
|
||||
$(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
|
||||
$(top_builddir)/lib/ext2fs/ext2_err.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
|
||||
$(top_srcdir)/lib/e2p/e2p.h
|
||||
resize2fs.o: $(srcdir)/resize2fs.c $(srcdir)/resize2fs.h \
|
||||
resize2fs.o: $(srcdir)/resize2fs.c $(top_builddir)/lib/config.h \
|
||||
$(top_builddir)/lib/dirpaths.h $(srcdir)/resize2fs.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
|
||||
$(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
|
||||
$(top_builddir)/lib/ext2fs/ext2_err.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
|
||||
$(top_srcdir)/lib/e2p/e2p.h
|
||||
main.o: $(srcdir)/main.c $(top_srcdir)/lib/e2p/e2p.h \
|
||||
main.o: $(srcdir)/main.c $(top_builddir)/lib/config.h \
|
||||
$(top_builddir)/lib/dirpaths.h $(top_srcdir)/lib/e2p/e2p.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
|
||||
$(srcdir)/resize2fs.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
|
||||
$(top_srcdir)/version.h
|
||||
online.o: $(srcdir)/online.c $(srcdir)/resize2fs.h \
|
||||
online.o: $(srcdir)/online.c $(top_builddir)/lib/config.h \
|
||||
$(top_builddir)/lib/dirpaths.h $(srcdir)/resize2fs.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
|
||||
$(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
|
||||
$(top_builddir)/lib/ext2fs/ext2_err.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
|
||||
$(top_srcdir)/lib/e2p/e2p.h
|
||||
sim_progress.o: $(srcdir)/sim_progress.c $(srcdir)/resize2fs.h \
|
||||
resource_track.o: $(srcdir)/resource_track.c $(top_builddir)/lib/config.h \
|
||||
$(top_builddir)/lib/dirpaths.h $(srcdir)/resize2fs.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
|
||||
$(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
|
||||
$(top_builddir)/lib/ext2fs/ext2_err.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_ext_attr.h $(top_srcdir)/lib/ext2fs/bitops.h \
|
||||
$(top_srcdir)/lib/e2p/e2p.h
|
||||
sim_progress.o: $(srcdir)/sim_progress.c $(top_builddir)/lib/config.h \
|
||||
$(top_builddir)/lib/dirpaths.h $(srcdir)/resize2fs.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
|
||||
$(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
|
||||
$(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
|
||||
|
|
|
@ -99,6 +99,8 @@ from the following list:
|
|||
4 \-\ Debug inode relocations
|
||||
.br
|
||||
8 \-\ Debug moving the inode table
|
||||
.br
|
||||
16 \-\ Print timing information
|
||||
.TP
|
||||
.B \-f
|
||||
Forces resize2fs to proceed with the filesystem resize operation, overriding
|
||||
|
|
|
@ -74,14 +74,7 @@ errcode_t resize_fs(ext2_filsys fs, blk64_t *new_size, int flags,
|
|||
{
|
||||
ext2_resize_t rfs;
|
||||
errcode_t retval;
|
||||
|
||||
retval = ext2fs_read_bitmaps(fs);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
fs->super->s_state |= EXT2_ERROR_FS;
|
||||
ext2fs_mark_super_dirty(fs);
|
||||
ext2fs_flush(fs);
|
||||
struct resource_track rtrack, overall_track;
|
||||
|
||||
/*
|
||||
* Create the data structure
|
||||
|
@ -89,32 +82,53 @@ errcode_t resize_fs(ext2_filsys fs, blk64_t *new_size, int flags,
|
|||
retval = ext2fs_get_mem(sizeof(struct ext2_resize_struct), &rfs);
|
||||
if (retval)
|
||||
return retval;
|
||||
memset(rfs, 0, sizeof(struct ext2_resize_struct));
|
||||
|
||||
fix_uninit_block_bitmaps(fs);
|
||||
memset(rfs, 0, sizeof(struct ext2_resize_struct));
|
||||
fs->priv_data = rfs;
|
||||
rfs->old_fs = fs;
|
||||
rfs->flags = flags;
|
||||
rfs->itable_buf = 0;
|
||||
rfs->progress = progress;
|
||||
|
||||
init_resource_track(&overall_track, "overall resize2fs", fs->io);
|
||||
init_resource_track(&rtrack, "read_bitmaps", fs->io);
|
||||
retval = ext2fs_read_bitmaps(fs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
fs->super->s_state |= EXT2_ERROR_FS;
|
||||
ext2fs_mark_super_dirty(fs);
|
||||
ext2fs_flush(fs);
|
||||
|
||||
init_resource_track(&rtrack, "fix_uninit_block_bitmaps 1", fs->io);
|
||||
fix_uninit_block_bitmaps(fs);
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
retval = ext2fs_dup_handle(fs, &rfs->new_fs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
|
||||
init_resource_track(&rtrack, "adjust_superblock", fs->io);
|
||||
retval = adjust_superblock(rfs, *new_size);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
|
||||
init_resource_track(&rtrack, "fix_uninit_block_bitmaps 2", fs->io);
|
||||
fix_uninit_block_bitmaps(rfs->new_fs);
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
/* Clear the block bitmap uninit flag for the last block group */
|
||||
ext2fs_bg_flags_clear(rfs->new_fs, rfs->new_fs->group_desc_count - 1,
|
||||
EXT2_BG_BLOCK_UNINIT);
|
||||
|
||||
*new_size = ext2fs_blocks_count(rfs->new_fs->super);
|
||||
|
||||
init_resource_track(&rtrack, "blocks_to_move", fs->io);
|
||||
retval = blocks_to_move(rfs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
#ifdef RESIZE2FS_DEBUG
|
||||
if (rfs->flags & RESIZE_DEBUG_BMOVE)
|
||||
|
@ -124,36 +138,52 @@ errcode_t resize_fs(ext2_filsys fs, blk64_t *new_size, int flags,
|
|||
rfs->needed_blocks);
|
||||
#endif
|
||||
|
||||
init_resource_track(&rtrack, "block_mover", fs->io);
|
||||
retval = block_mover(rfs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
init_resource_track(&rtrack, "inode_scan_and_fix", fs->io);
|
||||
retval = inode_scan_and_fix(rfs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
init_resource_track(&rtrack, "inode_ref_fix", fs->io);
|
||||
retval = inode_ref_fix(rfs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
init_resource_track(&rtrack, "move_itables", fs->io);
|
||||
retval = move_itables(rfs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
init_resource_track(&rtrack, "calculate_summary_stats", fs->io);
|
||||
retval = ext2fs_calculate_summary_stats(rfs->new_fs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
init_resource_track(&rtrack, "fix_resize_inode", fs->io);
|
||||
retval = fix_resize_inode(rfs->new_fs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
init_resource_track(&rtrack, "fix_sb_journal_backup", fs->io);
|
||||
retval = fix_sb_journal_backup(rfs->new_fs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
print_resource_track(rfs, &rtrack, fs->io);
|
||||
|
||||
rfs->new_fs->super->s_state &= ~EXT2_ERROR_FS;
|
||||
rfs->new_fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
|
||||
|
||||
print_resource_track(rfs, &overall_track, fs->io);
|
||||
retval = ext2fs_close(rfs->new_fs);
|
||||
if (retval)
|
||||
goto errout;
|
||||
|
@ -185,9 +215,9 @@ errout:
|
|||
*/
|
||||
static void fix_uninit_block_bitmaps(ext2_filsys fs)
|
||||
{
|
||||
blk64_t i, blk, super_blk, old_desc_blk, new_desc_blk;
|
||||
int old_desc_blocks;
|
||||
blk64_t blk, lblk;
|
||||
dgrp_t g;
|
||||
int i;
|
||||
|
||||
if (!ext2fs_has_group_desc_csum(fs))
|
||||
return;
|
||||
|
@ -196,35 +226,20 @@ static void fix_uninit_block_bitmaps(ext2_filsys fs)
|
|||
if (!(ext2fs_bg_flags_test(fs, g, EXT2_BG_BLOCK_UNINIT)))
|
||||
continue;
|
||||
|
||||
blk = (g * fs->super->s_blocks_per_group) +
|
||||
fs->super->s_first_data_block;
|
||||
blk = ext2fs_group_first_block2(fs, g);
|
||||
lblk = ext2fs_group_last_block2(fs, g);
|
||||
ext2fs_unmark_block_bitmap_range2(fs->block_map, blk,
|
||||
lblk - blk + 1);
|
||||
|
||||
ext2fs_super_and_bgd_loc2(fs, g, &super_blk,
|
||||
&old_desc_blk, &new_desc_blk, 0);
|
||||
|
||||
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
|
||||
old_desc_blocks = fs->super->s_first_meta_bg;
|
||||
else
|
||||
old_desc_blocks = fs->desc_blocks +
|
||||
fs->super->s_reserved_gdt_blocks;
|
||||
|
||||
for (i=0; i < fs->super->s_blocks_per_group; i++, blk++) {
|
||||
if (blk >= ext2fs_blocks_count(fs->super))
|
||||
break;
|
||||
if ((blk == super_blk) ||
|
||||
(old_desc_blk && old_desc_blocks &&
|
||||
(blk >= old_desc_blk) &&
|
||||
(blk < old_desc_blk + old_desc_blocks)) ||
|
||||
(new_desc_blk && (blk == new_desc_blk)) ||
|
||||
(blk == ext2fs_block_bitmap_loc(fs, g)) ||
|
||||
(blk == ext2fs_inode_bitmap_loc(fs, g)) ||
|
||||
(blk >= ext2fs_inode_table_loc(fs, g) &&
|
||||
(blk < ext2fs_inode_table_loc(fs, g)
|
||||
+ fs->inode_blocks_per_group)))
|
||||
ext2fs_fast_mark_block_bitmap2(fs->block_map, blk);
|
||||
else
|
||||
ext2fs_fast_unmark_block_bitmap2(fs->block_map, blk);
|
||||
}
|
||||
ext2fs_reserve_super_and_bgd(fs, g, fs->block_map);
|
||||
ext2fs_mark_block_bitmap2(fs->block_map,
|
||||
ext2fs_block_bitmap_loc(fs, g));
|
||||
ext2fs_mark_block_bitmap2(fs->block_map,
|
||||
ext2fs_inode_bitmap_loc(fs, g));
|
||||
for (i = 0, blk = ext2fs_inode_table_loc(fs, g);
|
||||
i < (unsigned int) fs->inode_blocks_per_group;
|
||||
i++, blk++)
|
||||
ext2fs_mark_block_bitmap2(fs->block_map, blk);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,9 +491,8 @@ retry:
|
|||
/*
|
||||
* Initialize the new block group descriptors
|
||||
*/
|
||||
group_block = fs->super->s_first_data_block +
|
||||
old_fs->group_desc_count * fs->super->s_blocks_per_group;
|
||||
|
||||
group_block = ext2fs_group_first_block2(fs,
|
||||
old_fs->group_desc_count);
|
||||
csum_flag = ext2fs_has_group_desc_csum(fs);
|
||||
if (access("/sys/fs/ext4/features/lazy_itable_init", F_OK) == 0)
|
||||
lazy_itable_init = 1;
|
||||
|
@ -634,9 +648,8 @@ static errcode_t adjust_superblock(ext2_resize_t rfs, blk64_t new_size)
|
|||
goto errout;
|
||||
|
||||
memset(rfs->itable_buf, 0, fs->blocksize * fs->inode_blocks_per_group);
|
||||
group_block = fs->super->s_first_data_block +
|
||||
rfs->old_fs->group_desc_count * fs->super->s_blocks_per_group;
|
||||
|
||||
group_block = ext2fs_group_first_block2(fs,
|
||||
rfs->old_fs->group_desc_count);
|
||||
adj = rfs->old_fs->group_desc_count;
|
||||
max_group = fs->group_desc_count - adj;
|
||||
if (rfs->progress) {
|
||||
|
@ -691,8 +704,6 @@ errout:
|
|||
static errcode_t mark_table_blocks(ext2_filsys fs,
|
||||
ext2fs_block_bitmap bmap)
|
||||
{
|
||||
blk64_t b;
|
||||
unsigned int j;
|
||||
dgrp_t i;
|
||||
|
||||
for (i = 0; i < fs->group_desc_count; i++) {
|
||||
|
@ -701,10 +712,9 @@ static errcode_t mark_table_blocks(ext2_filsys fs,
|
|||
/*
|
||||
* Mark the blocks used for the inode table
|
||||
*/
|
||||
for (j = 0, b = ext2fs_inode_table_loc(fs, i);
|
||||
j < (unsigned int) fs->inode_blocks_per_group;
|
||||
j++, b++)
|
||||
ext2fs_mark_block_bitmap2(bmap, b);
|
||||
ext2fs_mark_block_bitmap_range2(bmap,
|
||||
ext2fs_inode_table_loc(fs, i),
|
||||
fs->inode_blocks_per_group);
|
||||
|
||||
/*
|
||||
* Mark block used for the block bitmap
|
||||
|
@ -843,8 +853,7 @@ static errcode_t blocks_to_move(ext2_resize_t rfs)
|
|||
* The block bitmap is uninitialized, so skip
|
||||
* to the next block group.
|
||||
*/
|
||||
blk = ((g+1) * fs->super->s_blocks_per_group) +
|
||||
fs->super->s_first_data_block - 1;
|
||||
blk = ext2fs_group_first_block2(fs, g+1) - 1;
|
||||
continue;
|
||||
}
|
||||
if (ext2fs_test_block_bitmap2(old_fs->block_map, blk) &&
|
||||
|
@ -951,15 +960,13 @@ static errcode_t blocks_to_move(ext2_resize_t rfs)
|
|||
ext2fs_inode_bitmap_loc(old_fs, i));
|
||||
|
||||
if (ext2fs_inode_table_loc(fs, i))
|
||||
for (blk = ext2fs_inode_table_loc(fs, i), j=0;
|
||||
j < fs->inode_blocks_per_group ; j++, blk++)
|
||||
ext2fs_mark_block_bitmap2(rfs->reserve_blocks,
|
||||
blk);
|
||||
ext2fs_mark_block_bitmap_range2(rfs->reserve_blocks,
|
||||
ext2fs_inode_table_loc(fs, i),
|
||||
fs->inode_blocks_per_group);
|
||||
else if (flex_bg && i < old_fs->group_desc_count)
|
||||
for (blk = ext2fs_inode_table_loc(old_fs, i), j=0;
|
||||
j < old_fs->inode_blocks_per_group ; j++, blk++)
|
||||
ext2fs_mark_block_bitmap2(rfs->reserve_blocks,
|
||||
blk);
|
||||
ext2fs_mark_block_bitmap_range2(rfs->reserve_blocks,
|
||||
ext2fs_inode_table_loc(old_fs, i),
|
||||
old_fs->inode_blocks_per_group);
|
||||
|
||||
group_blk += rfs->new_fs->super->s_blocks_per_group;
|
||||
}
|
||||
|
@ -1794,7 +1801,8 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
|
|||
ext2_ino_t ino;
|
||||
unsigned int group = 0;
|
||||
unsigned int count = 0;
|
||||
int total_free = 0;
|
||||
blk64_t total_blocks_free = 0;
|
||||
int total_inodes_free = 0;
|
||||
int group_free = 0;
|
||||
int uninit = 0;
|
||||
blk64_t super_blk, old_desc_blk, new_desc_blk;
|
||||
|
@ -1826,7 +1834,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
|
|||
+ fs->inode_blocks_per_group))))) ||
|
||||
(!ext2fs_fast_test_block_bitmap2(fs->block_map, blk))) {
|
||||
group_free++;
|
||||
total_free++;
|
||||
total_blocks_free++;
|
||||
}
|
||||
count++;
|
||||
if ((count == fs->super->s_blocks_per_group) ||
|
||||
|
@ -1850,13 +1858,12 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
|
|||
fs->super->s_reserved_gdt_blocks;
|
||||
}
|
||||
}
|
||||
ext2fs_free_blocks_count_set(fs->super, total_free);
|
||||
ext2fs_free_blocks_count_set(fs->super, total_blocks_free);
|
||||
|
||||
/*
|
||||
* Next, calculate the inode statistics
|
||||
*/
|
||||
group_free = 0;
|
||||
total_free = 0;
|
||||
count = 0;
|
||||
group = 0;
|
||||
|
||||
|
@ -1866,7 +1873,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
|
|||
if (uninit ||
|
||||
!ext2fs_fast_test_inode_bitmap2(fs->inode_map, ino)) {
|
||||
group_free++;
|
||||
total_free++;
|
||||
total_inodes_free++;
|
||||
}
|
||||
count++;
|
||||
if ((count == fs->super->s_inodes_per_group) ||
|
||||
|
@ -1881,7 +1888,7 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
|
|||
uninit = ext2fs_bg_flags_test(fs, group, EXT2_BG_INODE_UNINIT);
|
||||
}
|
||||
}
|
||||
fs->super->s_free_inodes_count = total_free;
|
||||
fs->super->s_free_inodes_count = total_inodes_free;
|
||||
ext2fs_mark_super_dirty(fs);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -76,10 +76,25 @@ typedef struct ext2_sim_progress *ext2_sim_progmeter;
|
|||
#define RESIZE_DEBUG_BMOVE 0x0002
|
||||
#define RESIZE_DEBUG_INODEMAP 0x0004
|
||||
#define RESIZE_DEBUG_ITABLEMOVE 0x0008
|
||||
#define RESIZE_DEBUG_RTRACK 0x0010
|
||||
|
||||
#define RESIZE_PERCENT_COMPLETE 0x0100
|
||||
#define RESIZE_VERBOSE 0x0200
|
||||
|
||||
/*
|
||||
* This structure is used for keeping track of how much resources have
|
||||
* been used for a particular resize2fs pass.
|
||||
*/
|
||||
struct resource_track {
|
||||
const char *desc;
|
||||
struct timeval time_start;
|
||||
struct timeval user_start;
|
||||
struct timeval system_start;
|
||||
void *brk_start;
|
||||
unsigned long long bytes_read;
|
||||
unsigned long long bytes_written;
|
||||
};
|
||||
|
||||
/*
|
||||
* The core state structure for the ext2 resizer
|
||||
*/
|
||||
|
@ -148,6 +163,13 @@ extern errcode_t ext2fs_iterate_extent(ext2_extent extent, __u64 *old_loc,
|
|||
extern errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
|
||||
blk64_t *new_size, int flags);
|
||||
|
||||
/* resource_track.c */
|
||||
extern void init_resource_track(struct resource_track *track, const char *desc,
|
||||
io_channel channel);
|
||||
extern void print_resource_track(ext2_resize_t rfs,
|
||||
struct resource_track *track,
|
||||
io_channel channel);
|
||||
|
||||
/* sim_progress.c */
|
||||
extern errcode_t ext2fs_progress_init(ext2_sim_progmeter *ret_prog,
|
||||
const char *label,
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* resource_track.c --- resource tracking
|
||||
*
|
||||
* Copyright (C) 2013 by Theodore Ts'o
|
||||
*
|
||||
* %Begin-Header%
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
* %End-Header%
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "resize2fs.h"
|
||||
#include <time.h>
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <sys/resource.h>
|
||||
|
||||
void init_resource_track(struct resource_track *track, const char *desc,
|
||||
io_channel channel)
|
||||
{
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
struct rusage r;
|
||||
#endif
|
||||
io_stats io_start = 0;
|
||||
|
||||
track->desc = desc;
|
||||
track->brk_start = sbrk(0);
|
||||
gettimeofday(&track->time_start, 0);
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
#ifdef sun
|
||||
memset(&r, 0, sizeof(struct rusage));
|
||||
#endif
|
||||
getrusage(RUSAGE_SELF, &r);
|
||||
track->user_start = r.ru_utime;
|
||||
track->system_start = r.ru_stime;
|
||||
#else
|
||||
track->user_start.tv_sec = track->user_start.tv_usec = 0;
|
||||
track->system_start.tv_sec = track->system_start.tv_usec = 0;
|
||||
#endif
|
||||
track->bytes_read = 0;
|
||||
track->bytes_written = 0;
|
||||
if (channel && channel->manager && channel->manager->get_stats)
|
||||
channel->manager->get_stats(channel, &io_start);
|
||||
if (io_start) {
|
||||
track->bytes_read = io_start->bytes_read;
|
||||
track->bytes_written = io_start->bytes_written;
|
||||
}
|
||||
}
|
||||
|
||||
static float timeval_subtract(struct timeval *tv1,
|
||||
struct timeval *tv2)
|
||||
{
|
||||
return ((tv1->tv_sec - tv2->tv_sec) +
|
||||
((float) (tv1->tv_usec - tv2->tv_usec)) / 1000000);
|
||||
}
|
||||
|
||||
void print_resource_track(ext2_resize_t rfs, struct resource_track *track,
|
||||
io_channel channel)
|
||||
{
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
struct rusage r;
|
||||
#endif
|
||||
#ifdef HAVE_MALLINFO
|
||||
struct mallinfo malloc_info;
|
||||
#endif
|
||||
struct timeval time_end;
|
||||
|
||||
if ((rfs->flags & RESIZE_DEBUG_RTRACK) == 0)
|
||||
return;
|
||||
|
||||
gettimeofday(&time_end, 0);
|
||||
|
||||
if (track->desc)
|
||||
printf("%s: ", track->desc);
|
||||
|
||||
#ifdef HAVE_MALLINFO
|
||||
#define kbytes(x) (((unsigned long)(x) + 1023) / 1024)
|
||||
|
||||
malloc_info = mallinfo();
|
||||
printf("Memory used: %luk/%luk (%luk/%luk), ",
|
||||
kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
|
||||
kbytes(malloc_info.uordblks), kbytes(malloc_info.fordblks));
|
||||
#else
|
||||
printf("Memory used: %lu, ",
|
||||
(unsigned long) (((char *) sbrk(0)) -
|
||||
((char *) track->brk_start)));
|
||||
#endif
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
getrusage(RUSAGE_SELF, &r);
|
||||
|
||||
printf("time: %5.2f/%5.2f/%5.2f\n",
|
||||
timeval_subtract(&time_end, &track->time_start),
|
||||
timeval_subtract(&r.ru_utime, &track->user_start),
|
||||
timeval_subtract(&r.ru_stime, &track->system_start));
|
||||
#else
|
||||
printf("elapsed time: %6.3f\n",
|
||||
timeval_subtract(&time_end, &track->time_start));
|
||||
#endif
|
||||
#define mbytes(x) (((x) + 1048575) / 1048576)
|
||||
if (channel && channel->manager && channel->manager->get_stats) {
|
||||
io_stats delta = 0;
|
||||
unsigned long long bytes_read = 0;
|
||||
unsigned long long bytes_written = 0;
|
||||
|
||||
channel->manager->get_stats(channel, &delta);
|
||||
if (delta) {
|
||||
bytes_read = delta->bytes_read - track->bytes_read;
|
||||
bytes_written = delta->bytes_written -
|
||||
track->bytes_written;
|
||||
if (bytes_read == 0 && bytes_written == 0)
|
||||
goto skip_io;
|
||||
if (track->desc)
|
||||
printf("%s: ", track->desc);
|
||||
printf("I/O read: %lluMB, write: %lluMB, "
|
||||
"rate: %.2fMB/s\n",
|
||||
mbytes(bytes_read),
|
||||
mbytes(bytes_written),
|
||||
(double)mbytes(bytes_read + bytes_written) /
|
||||
timeval_subtract(&time_end, &track->time_start));
|
||||
}
|
||||
}
|
||||
skip_io:
|
||||
fflush(stdout);
|
||||
}
|
||||
|
Loading…
Reference in New Issue