* [U-Boot] [PATCH 1/2] fdt: Add new fdt_set_node_status & fdt_set_status_by_alias helpers
From: Wolfgang Denk @ 2011-10-23 8:49 UTC (permalink / raw)
To: u-boot
In-Reply-To: <1318619444-2059-1-git-send-email-galak@kernel.crashing.org>
Dear Kumar Gala,
In message <1318619444-2059-1-git-send-email-galak@kernel.crashing.org> you wrote:
> From: Shengzhou Liu <Shengzhou.Liu@freescale.com>
>
> Add common function fdt_set_node_status() to assist in various locations
> that we set a nodes status. This function utilizes the status values
> that are part of the EPAPR spec (on power.org).
>
> fdt_set_status_by_alias() is based on fdt_set_node_status() but uses an
> alias string to identify the node to update.
>
> We also add some shortcut functions to help the common cases of setting
> "okay" and "disabled":
>
> fdt_status_okay()
> fdt_status_disabled()
> fdt_status_okay_by_alias()
> fdt_status_disabled_by_alias()
>
> Finally, we fixup the corenet_ds ethernet code which previously had
> a function by the same name that can be replaced with the new helpers.
>
> Signed-off-by: Shengzhou Liu <Shengzhou.Liu@freescale.com>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
This patch breaks a number of boards by growing the code size even for
boards which never make use of this new stuff.
Affected boards: TQM8555 TQM8541
[Building with ELDK 4.2]:
+ ./MAKEALL TQM8555
Configuring for TQM8555 - Board: TQM85xx, Options: MPC8555,TQM8555=y,HOSTNAME=tqm8555,BOARDNAME="TQM8555"
ppc_6xx-ld: warning: dot moved backwards before `.bss'
ppc_6xx-ld: warning: dot moved backwards before `.bss'
ppc_6xx-ld: u-boot: section .text lma 0xfffc0000 overlaps previous sections
ppc_6xx-ld: u-boot: section .rodata lma 0xfffef388 overlaps previous sections
ppc_6xx-ld: u-boot: section .reloc lma 0xffffa400 overlaps previous sections
ppc_6xx-ld: u-boot: section .data lma 0xffffcd3c overlaps previous sections
ppc_6xx-ld: u-boot: section .u_boot_cmd lma 0xffffea68 overlaps previous sections
ppc_6xx-ld: u-boot: section .bootpg lma 0xfffff0dc overlaps previous sections
Please fix.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Each honest calling, each walk of life, has its own elite, its own
aristocracy based on excellence of performance. - James Bryant Conant
^ permalink raw reply
* [Bug 36934] screen corruption after running a game
From: bugzilla-daemon @ 2011-10-23 8:49 UTC (permalink / raw)
To: dri-devel
In-Reply-To: <bug-36934-502@http.bugs.freedesktop.org/>
https://bugs.freedesktop.org/show_bug.cgi?id=36934
--- Comment #16 from auxsvr@gmail.com 2011-10-23 01:49:26 PDT ---
The type of minor, transient corruption described in comment 14 is this: some
glyphs or stripes of a widget become transparent for some seconds or minutes.
This is unlike the original corruption, which would garble the display,
rendering X unusable.
--
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
^ permalink raw reply
* [U-Boot] [PATCH 2/2] serial: uartlite: Fix compilation warnings
From: Wolfgang Denk @ 2011-10-23 8:52 UTC (permalink / raw)
To: u-boot
In-Reply-To: <1318933330-17883-2-git-send-email-monstr@monstr.eu>
Dear Michal Simek,
In message <1318933330-17883-2-git-send-email-monstr@monstr.eu> you wrote:
> Do not setup userial_ports array as const because
> in uartlite_serial_putc is out_be32 which can't write
> to tx_fifo if is const.
>
> Warning log:
> serial_xuartlite.c: In function 'uartlite_serial_putc':
> serial_xuartlite.c:60: warning: initialization discards qualifiers from pointer target type
> serial_xuartlite.c: In function 'uartlite_serial_getc':
> serial_xuartlite.c:78: warning: initialization discards qualifiers from pointer target type
> serial_xuartlite.c: In function 'uartlite_serial_tstc':
> serial_xuartlite.c:87: warning: initialization discards qualifiers from pointer target type
>
> Signed-off-by: Michal Simek <monstr@monstr.eu>
>
> ---
> There are several approach how to solve it in uartlite_serial_putc.
> 1. add retype to out_be32 function
> 2. retype in assignment
> 3. do not define userial_ports as const - used solution
Wouldn't 1. and 2. actually be wrong? If you need to write to the
struct, you must not declare it as constant?
> ---
> drivers/serial/serial_xuartlite.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
God made the integers; all else is the work of Man. - Kronecker
^ permalink raw reply
* Re: [patch net-next V2] net: introduce ethernet teaming device
From: Jiri Pirko @ 2011-10-23 8:52 UTC (permalink / raw)
To: Eric Dumazet
Cc: netdev, davem, bhutchings, shemminger, fubar, andy, tgraf,
ebiederm, mirqus, kaber, greearb, jesse, fbl, benjamin.poirier,
jzupka
In-Reply-To: <1319359437.6180.73.camel@edumazet-laptop>
Sun, Oct 23, 2011 at 10:43:57AM CEST, eric.dumazet@gmail.com wrote:
>Le dimanche 23 octobre 2011 à 10:25 +0200, Jiri Pirko a écrit :
>> Sat, Oct 22, 2011 at 06:51:22PM CEST, eric.dumazet@gmail.com wrote:
>> >Le samedi 22 octobre 2011 à 17:13 +0200, Jiri Pirko a écrit :
>> >> >> +
>> >> >> +/************************
>> >> >> + * Rx path frame handler
>> >> >> + ************************/
>> >> >> +
>> >> >> +/* note: already called with rcu_read_lock */
>> >> >> +static rx_handler_result_t team_handle_frame(struct sk_buff **pskb)
>> >> >> +{
>> >> >> + struct sk_buff *skb = *pskb;
>> >> >> + struct team_port *port;
>> >> >> + struct team *team;
>> >> >> + rx_handler_result_t res = RX_HANDLER_ANOTHER;
>> >> >> +
>> >> >> + skb = skb_share_check(skb, GFP_ATOMIC);
>> >> >> + if (!skb)
>> >> >> + return RX_HANDLER_CONSUMED;
>> >> >> +
>> >> >> + *pskb = skb;
>> >> >> +
>> >> >> + port = team_port_get_rcu(skb->dev);
>> >> >> + team = port->team;
>> >> >> +
>> >> >> + if (team->mode_ops.receive)
>> >> >
>> >> >Hmm, you need ACCESS_ONCE() here or rcu_dereference()
>> >> >
>> >> >See commit 4d97480b1806e883eb (bonding: use local function pointer of
>> >> >bond->recv_probe in bond_handle_frame) for reference
>> >>
>> >> I do not think so. Because mode_ops.receive changes only from
>> >> __team_change_mode() and this can be called only in case no ports are in
>> >> team. And team_port_del() calls synchronize_rcu().
>> >>
>> >
>> >
>> >
>> >We are used to code following this template :
>> >
>> >if (ops->handler)
>> > ops->handler(arguments);
>> >
>> >But this is valid only because ops points to constant memory.
>> >
>> >
>> >In your case, we really see its not true, dont try to pretend its safe.
>>
>> Please forgive me, it's possible I'm missing something. But I see no way how
>> team->mode_ops.receive can change during team_handle_frame (holding
>> rcu_read_lock) for the reason I stated earlier.
>>
>> team_port_del() calls netdev_rx_handler_unregister() and after that it
>> calls synchronize_rcu(). That ensures that by the finish of team_port_del()
>> run, team_handle_frame() is not called for this port anymore.
>>
>> And this combined with "if (!list_empty(&team->port_list))" check in
>> team_change_mode() ensures safety.
>>
>> Of course team_port_del() and team_change_mode() are both protected by
>> team->lock so they are mutually excluded.
>
>Then, why even testing (team->mode_ops.receive) being NULL at the first
>place, if you are sure no packets can flight meeting this NULL pointer ?
>
>Something is flawed in the logic.
It's not :) The test is simply because a mode may not implement this
callback (actually "roundrobin" mode doesn't have this implemented).
Jirka
>
>
>
^ permalink raw reply
* Re: [RFC] subdevice PM: .s_power() deprecation?
From: Sylwester Nawrocki @ 2011-10-23 9:01 UTC (permalink / raw)
To: Sakari Ailus
Cc: Guennadi Liakhovetski, Laurent Pinchart, Linux Media Mailing List,
Tomasz Stanislawski
In-Reply-To: <4EA3D3F8.907@iki.fi>
On 10/23/2011 10:44 AM, Sakari Ailus wrote:
> Sylwester Nawrocki wrote:
...
>>>> 2. In some of our camera pipeline setups - "Sensor - MIPI-CSI receiver - host/DMA",
>>>> the sensor won't boot properly if all MIPI-CSI regulators aren't enabled. So the
>>>> MIPI-CSI receiver must always be powered on before the sensor. With the subdevs
>>>> doing their own magic wrt to power control the situation is getting slightly
>>>> out of control.
>>>
>>> How about this: CSI-2 receiver implements a few new regulators which the
>>> sensor driver then requests to be enabled. Would that work for you?
>>
>> No, I don't like that... :)
>>
>> We would have to standardize the regulator supply names, etc. Such approach
>> would be more difficult to align with runtime/system suspend/resume.
>> Also the sensor drivers should be independent on other drivers. The MIPI-CSI
>> receiver is more specific to the host, rather than a sensor.
>>
>> Not all sensors need MIPI-CSI, some just use parallel video bus.
>
> The sensor drivers are responsible for the regulators they want to use,
> right? If they need no CSI-2 related regulators then they just ignore
Only for the regulator supplies for their device. In this case the sensor
driver would have to touch MIPI-CSI device regulator supplies.
> them as any other regulators the sensor doesn't need.
>
> The names of the regulators could come from the platform data, they're
> board specific anyway. I can't see another way to do this without having
No, you don't want regulator supply names in any platform data struct.
The platform code binds regulator supplies to the devices, whether it is DT
based or not.
> platform code to do this which is not quite compatible with the idea of
> the device tree.
Now I just use s_power callback in our drivers and it all works well.
--
Regards,
Sylwester
^ permalink raw reply
* [RFC][PATCH] uncompress.h cleanup and DT support
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-10-23 9:02 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <CAGVye5MSqdxh0DzCMt79sKk+Z0Trfro0RNDr-4zccMh7O7vGiA@mail.gmail.com>
On 10:18 Sun 23 Oct , Zoltan Devai wrote:
> Hi,
>
> Originally, I just wanted to get rid of arch_decomp_* in all the uncompress.h
> files, that were mostly empty. But then, I couldn't stop. Which may also mean
> I have gone too far.
on small SoC arm926 the kernel may more time that the watchdog refreshing so
the kernel will never have enough time to decompress
and on some platform the watchdog can be configured only one (AT91 as example)
Best Regards,
J.
^ permalink raw reply
* Re: MD devnode still present after 'remove' udev event, and mdadm reports 'does not appear to be active'
From: Alexander Lyakas @ 2011-10-23 9:03 UTC (permalink / raw)
To: NeilBrown; +Cc: linux-raid
In-Reply-To: <20111020105623.7f8038c9@notabene.brown>
Thanks, Neil.
To end this long email thread: what is "more important": update time
or event count? Or perhaps they are updated simultaneously?
Thanks,
Alex.
On Thu, Oct 20, 2011 at 1:56 AM, NeilBrown <neilb@suse.de> wrote:
> On Wed, 19 Oct 2011 14:01:16 +0200 Alexander Lyakas <alex.bolshoy@gmail.com>
> wrote:
>
>> Thanks, Neil.
>> I experimented with --force switch, and I saw that when using this
>> switch it is possible to start the array, even though I am sure that
>> the data will be corrupted. Such as selecting stale drives (which have
>> been replaced previously etc.)
>> Can I have some indication that it is "relatively safe" to start the
>> array with --force?
>> For example, in the case of "dirty degraded", perhaps it might be
>> relatively safe.
>>
>> What should I look at? The output of --examine? Or something else?
>
> Yes, look at the output of examine. Look particularly at update time and
> event counts, but also at RAID raid level etc and the role in the array
> played by each device.
>
> Then choose the set of devices that you should are most likely to have
> current data and given them to "mdadm --assemble --force".
>
> Obviously if one device hasn't been updated for months, that is probably a
> bad choice, while if one device is only a few minutes behind the others, then
> that is probably a good choice.
>
> Normally there isn't much choice to be made, and the answer will be obvious.
> But if you let devices fail and leave them lying around, or don't replace
> them, then that can cause problems.
>
> If you need to use --force there might be some corruption. Or there might
> be none. And there could be a lot. But mdadm has know way of knowing.
> Usually mdadm will do the best that is possible, but it cannot know how good
> that is.
>
> NeilBrown
>
>
>
>>
>> Thanks,
>> Alex.
>>
>>
>> On Wed, Oct 12, 2011 at 5:45 AM, NeilBrown <neilb@suse.de> wrote:
>> > On Tue, 11 Oct 2011 15:11:47 +0200 Alexander Lyakas <alex.bolshoy@gmail.com>
>> > wrote:
>> >
>> >> Hello Neil,
>> >> can you please confirm for me something?
>> >> In case the array is FAILED (when your enough() function returns 0) -
>> >> for example, after simultaneous failure of all drives - then the only
>> >> option to try to recover such array is to do:
>> >> mdadm --stop
>> >> and then attempt
>> >> mdadm --assemble
>> >>
>> >> correct?
>> >
>> > Yes, though you will probably want a --force as well.
>> >
>> >>
>> >> I did not see any other option to recover such array Incremental
>> >> assemble doesn't work in that case, it simply adds back the drives as
>> >> spares.
>> >
>> > In recent version of mdadm it shouldn't add them as spare. It should say
>> > that it cannot add it and give up.
>> >
>> > NeilBrown
>> >
>> >
>> >
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] ipv4: fix ipsec forward performance regression
From: Eric Dumazet @ 2011-10-23 9:03 UTC (permalink / raw)
To: Yan, Zheng; +Cc: netdev@vger.kernel.org, davem@davemloft.net, Kim Phillips
In-Reply-To: <4EA3C91C.3090801@intel.com>
Le dimanche 23 octobre 2011 à 15:58 +0800, Yan, Zheng a écrit :
> There is bug in commit 5e2b61f(ipv4: Remove flowi from struct rtable).
> It makes xfrm4_fill_dst() modify wrong data structure.
>
> Signed-off-by: Zheng Yan <zheng.z.yan@intel.com>
> ---
> net/ipv4/xfrm4_policy.c | 14 +++++++-------
> 1 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
> index fc5368a..a0b4c5d 100644
> --- a/net/ipv4/xfrm4_policy.c
> +++ b/net/ipv4/xfrm4_policy.c
> @@ -79,13 +79,13 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
> struct rtable *rt = (struct rtable *)xdst->route;
> const struct flowi4 *fl4 = &fl->u.ip4;
>
> - rt->rt_key_dst = fl4->daddr;
> - rt->rt_key_src = fl4->saddr;
> - rt->rt_key_tos = fl4->flowi4_tos;
> - rt->rt_route_iif = fl4->flowi4_iif;
> - rt->rt_iif = fl4->flowi4_iif;
> - rt->rt_oif = fl4->flowi4_oif;
> - rt->rt_mark = fl4->flowi4_mark;
> + xdst->u.rt.rt_key_dst = fl4->daddr;
> + xdst->u.rt.rt_key_src = fl4->saddr;
> + xdst->u.rt.rt_key_tos = fl4->flowi4_tos;
> + xdst->u.rt.rt_route_iif = fl4->flowi4_iif;
> + xdst->u.rt.rt_iif = fl4->flowi4_iif;
> + xdst->u.rt.rt_oif = fl4->flowi4_oif;
> + xdst->u.rt.rt_mark = fl4->flowi4_mark;
>
> xdst->u.dst.dev = dev;
> dev_hold(dev);
Good catch, thanks !
Reported-by: Kim Phillips <kim.phillips@freescale.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
^ permalink raw reply
* [PATCH 2/3] ARM: AT91: IIO: Add AT91 ADC driver.
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-10-23 9:08 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <1319041134-19712-3-git-send-email-maxime.ripard@free-electrons.com>
On 18:18 Wed 19 Oct , Maxime Ripard wrote:
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> Cc: Patrice Vilchez <patrice.vilchez@atmel.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
please keep me in CC
> +
> +static int at91adc_channel_init(struct at91adc_state *st)
> +{
> + int ret = 0, i;
> + st->channels = kzalloc(sizeof(struct iio_chan_spec) * st->nb_chan,
> + GFP_KERNEL);
> + if (st->channels == NULL)
> + return -ENOMEM;
> +
> + for (i = 0; i < st->nb_chan; i++) {
> + struct iio_chan_spec *chan = st->channels + i;
> + chan->type = IIO_VOLTAGE;
> + chan->indexed = 1;
> + chan->channel = i;
> + ++ret;
> + }
> +
> + return ret;
> +}
> +
> +static int at91adc_read_raw(struct iio_dev *idev,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2, long mask)
> +{
> + struct at91adc_state *st = iio_priv(idev);
> +
> + switch (mask) {
> + case 0:
> + mutex_lock(&st->lock);
> +
> + at91adc_reg_write(st->reg_base, AT91_ADC_CHER,
> + AT91_ADC_CH(chan->channel));
> + at91adc_reg_write(st->reg_base, AT91_ADC_IER,
> + AT91_ADC_EOC(chan->channel));
> + at91adc_reg_write(st->reg_base, AT91_ADC_CR, AT91_ADC_START);
> +
> + wait_event_interruptible(st->wq_data_avail, st->done);
> + *val = st->lcdr;
> +
> + at91adc_reg_write(st->reg_base, AT91_ADC_CHDR,
> + AT91_ADC_CH(chan->channel));
> + at91adc_reg_write(st->reg_base, AT91_ADC_IDR,
> + AT91_ADC_EOC(chan->channel));
> +
> + st->lcdr = 0;
> + st->done = false;
> + mutex_unlock(&st->lock);
> + return IIO_VAL_INT;
> + default:
> + break;
> + }
> + return -EINVAL;
> +}
> +
> +static const struct iio_info at91adc_info = {
> + .driver_module = THIS_MODULE,
> + .read_raw = &at91adc_read_raw,
> +};
> +
> +static int __devinit at91adc_probe(struct platform_device *pdev)
> +{
> + unsigned int prsc, mstrclk, ticks;
> + int ret;
> + struct iio_dev *idev;
> + struct at91adc_state *st;
> + struct resource *res;
> + struct at91_adc_data *pdata = pdev->dev.platform_data;
do not refence it copy need for the DT
> +
> + dev_dbg(&pdev->dev, "AT91ADC probed\n");
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res) {
> + dev_err(&pdev->dev, "No resource defined\n");
> + ret = -ENXIO;
> + goto error_ret;
> + }
> +
> + idev = iio_allocate_device(sizeof(*st));
> + if (idev == NULL) {
> + dev_err(&pdev->dev, "Failed to allocate memory.\n");
> + ret = -ENOMEM;
> + goto error_ret;
> + }
> + platform_set_drvdata(pdev, idev);
> +
> + idev->dev.parent = &pdev->dev;
> + idev->name = platform_get_device_id(pdev)->name;
> + idev->modes = INDIO_DIRECT_MODE;
> + idev->info = &at91adc_info;
> +
> + st = iio_priv(idev);
> + st->irq = platform_get_irq(pdev, 0);
> + if (st->irq < 0) {
> + dev_err(&pdev->dev, "No IRQ ID is designated\n");
> + ret = -ENODEV;
> + goto error_free_device;
> + }
> +
> + if (!request_mem_region(res->start, resource_size(res),
> + "AT91 adc registers")) {
> + dev_err(&pdev->dev, "Resources are unavailable.\n");
> + ret = -EBUSY;
> + goto error_free_device;
> + }
> +
> + st->reg_base = ioremap(res->start, resource_size(res));
> + if (!st->reg_base) {
> + dev_err(&pdev->dev, "Failed to map registers.\n");
> + ret = -ENOMEM;
> + goto error_release_mem;
> + }
> +
> + /*
> + * Disable all IRQs before setting up the handler
> + */
> + at91adc_reg_write(st->reg_base, AT91_ADC_CR, AT91_ADC_SWRST);
> + at91adc_reg_write(st->reg_base, AT91_ADC_IDR, 0xFFFFFFFF);
> + ret = request_irq(st->irq,
> + at91adc_eoc_trigger, 0, pdev->dev.driver->name, st);
> + if (ret) {
> + dev_err(&pdev->dev, "Failed to allocate IRQ.\n");
> + goto error_unmap_reg;
> + }
> +
> + st->clk = clk_get(&pdev->dev, "adc_clk");
> + if (IS_ERR(st->clk)) {
> + dev_err(&pdev->dev, "Failed to get the clock.\n");
> + ret = PTR_ERR(st->clk);
> + goto error_free_irq;
> + }
> +
> + clk_enable(st->clk);
> + mstrclk = clk_get_rate(st->clk);
> +
> + if (!pdata) {
> + dev_err(&pdev->dev, "No platform data available.\n");
> + ret = -EINVAL;
> + goto error_free_clk;
> + }
> +
> + if (!pdata->adc_clock) {
> + dev_err(&pdev->dev, "No ADCClock available.\n");
> + ret = -EINVAL;
> + goto error_free_clk;
> + }
where is the platform data struct?
Best Regards,
J.
^ permalink raw reply
* e2fsprogs: add exclude bitmap support in e2fsprogs
From: Yongqiang Yang @ 2011-10-23 7:21 UTC (permalink / raw)
To: linux-ext4; +Cc: amir73il
Hi,
Exclude bitmap(also known as snapshot bitmap) feature is needed
by ext4 snapshot. This patch series add exlcude bitmap in e2fsprogs
except resize. Kernel-side patches for resize which can support
exclude bitmap and bigalloc are still waiting for merging.
Yongqiang.
^ permalink raw reply
* [PATCH 1/8] e2fsprogs: add exclude bitmap support in libext2fs
From: Yongqiang Yang @ 2011-10-23 7:21 UTC (permalink / raw)
To: linux-ext4; +Cc: amir73il, Yongqiang Yang
In-Reply-To: <1319354488-6050-1-git-send-email-xiaoqiangnk@gmail.com>
Exclude bitmap is needed by ext4 snapshot. This patch adds
exclude bitmap support in libext2fs.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
Signed-off-by: Amir Goldstein <amir73il@users.sf.net>
---
lib/e2p/ls.c | 13 ++++
lib/ext2fs/alloc.c | 3 +
lib/ext2fs/alloc_tables.c | 44 ++++++++++++++-
lib/ext2fs/bitmaps.c | 70 +++++++++++++++++++++++
lib/ext2fs/blknum.c | 27 +++++++++
lib/ext2fs/bmap64.h | 2 +
lib/ext2fs/csum.c | 5 +-
lib/ext2fs/dupfs.c | 5 ++
lib/ext2fs/ext2_err.et.in | 21 +++++++
lib/ext2fs/ext2_fs.h | 2 +
lib/ext2fs/ext2fs.h | 28 +++++++++
lib/ext2fs/freefs.c | 2 +
lib/ext2fs/gen_bitmap.c | 48 ++++++++++++++++
lib/ext2fs/gen_bitmap64.c | 3 +
lib/ext2fs/initialize.c | 16 +++++
lib/ext2fs/openfs.c | 2 +
lib/ext2fs/rw_bitmaps.c | 136 ++++++++++++++++++++++++++++++++++++++++-----
lib/ext2fs/swapfs.c | 2 +
18 files changed, 409 insertions(+), 20 deletions(-)
diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c
index f05e16d..0cd5b37 100644
--- a/lib/e2p/ls.c
+++ b/lib/e2p/ls.c
@@ -161,6 +161,19 @@ static void print_super_flags(struct ext2_super_block * s, FILE *f)
fputs("test_filesystem ", f);
flags_found++;
}
+ if (s->s_flags & EXT2_FLAGS_IS_SNAPSHOT) {
+ fputs("is_snapshot ", f);
+ flags_found++;
+ }
+ if (s->s_flags & EXT2_FLAGS_FIX_SNAPSHOT) {
+ fputs("fix_snapshot ", f);
+ flags_found++;
+ }
+ if (s->s_flags & EXT2_FLAGS_FIX_EXCLUDE) {
+ fputs("fix_snapshot_bitmap ", f);
+ flags_found++;
+ }
+
if (flags_found)
fputs("\n", f);
else
diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c
index 948a0ec..a0b91dd 100644
--- a/lib/ext2fs/alloc.c
+++ b/lib/ext2fs/alloc.c
@@ -65,6 +65,9 @@ static void check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,
(blk < old_desc_blk + old_desc_blocks)) ||
(new_desc_blk && (blk == new_desc_blk)) ||
(blk == ext2fs_block_bitmap_loc(fs, group)) ||
+ (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ (blk == ext2fs_exclude_bitmap_loc(fs, group))) ||
(blk == ext2fs_inode_bitmap_loc(fs, group)) ||
(blk >= ext2fs_inode_table_loc(fs, group) &&
(blk < ext2fs_inode_table_loc(fs, group)
diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index 9f3d4e0..b5e2f0c 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -87,7 +87,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
errcode_t retval;
blk64_t group_blk, start_blk, last_blk, new_blk, blk;
dgrp_t last_grp = 0;
- int rem_grps = 0, flexbg_size = 0;
+ int rem_grps = 0, flexbg_size = 0, exclude_bitmap = 0;
group_blk = ext2fs_group_first_block2(fs, group);
last_blk = ext2fs_group_last_block2(fs, group);
@@ -105,8 +105,12 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
rem_grps = last_grp - group + 1;
}
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP))
+ exclude_bitmap = 1;
+
/*
- * Allocate the block and inode bitmaps, if necessary
+ * Allocate the block, exclude and inode bitmaps, if necessary
*/
if (fs->stride) {
retval = ext2fs_get_free_blocks2(fs, group_blk, last_blk,
@@ -150,13 +154,47 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
}
}
+ if (exclude_bitmap && flexbg_size) {
+ blk64_t prev_block = 0;
+
+ if (group % flexbg_size)
+ prev_block = ext2fs_exclude_bitmap_loc(fs, group - 1) + 1;
+ else
+ prev_block = ext2fs_block_bitmap_loc(fs, group) +
+ flexbg_size;
+ start_blk = flexbg_offset(fs, group, prev_block, bmap,
+ rem_grps, 1);
+ last_blk = ext2fs_group_last_block2(fs, last_grp);
+ }
+
+ if (exclude_bitmap && !ext2fs_exclude_bitmap_loc(fs, group)) {
+ retval = ext2fs_get_free_blocks2(fs, start_blk, last_blk,
+ 1, bmap, &new_blk);
+ if (retval == EXT2_ET_BLOCK_ALLOC_FAIL)
+ retval = ext2fs_get_free_blocks2(fs, group_blk,
+ last_blk, 1, bmap, &new_blk);
+ if (retval)
+ return retval;
+ ext2fs_mark_block_bitmap2(bmap, new_blk);
+ ext2fs_exclude_bitmap_loc_set(fs, group, new_blk);
+ if (flexbg_size) {
+ dgrp_t gr = ext2fs_group_of_blk2(fs, new_blk);
+ ext2fs_bg_free_blocks_count_set(fs, gr,
+ ext2fs_bg_free_blocks_count(fs, gr) - 1);
+ ext2fs_free_blocks_count_add(fs->super, -1);
+ ext2fs_bg_flags_clear(fs, gr, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_group_desc_csum_set(fs, gr);
+ }
+ }
+
if (flexbg_size) {
blk64_t prev_block = 0;
if (group % flexbg_size)
prev_block = ext2fs_inode_bitmap_loc(fs, group - 1) + 1;
else
- prev_block = ext2fs_block_bitmap_loc(fs, group) +
+ prev_block = ext2fs_exclude_bitmap_loc(fs, group) +
flexbg_size;
+
start_blk = flexbg_offset(fs, group, prev_block, bmap,
rem_grps, 1);
last_blk = ext2fs_group_last_block2(fs, last_grp);
diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c
index e518295..4709fa2 100644
--- a/lib/ext2fs/bitmaps.c
+++ b/lib/ext2fs/bitmaps.c
@@ -35,6 +35,11 @@ void ext2fs_free_inode_bitmap(ext2fs_inode_bitmap bitmap)
ext2fs_free_generic_bmap(bitmap);
}
+void ext2fs_free_exclude_bitmap(ext2fs_exclude_bitmap bitmap)
+{
+ ext2fs_free_generic_bmap(bitmap);
+}
+
void ext2fs_free_block_bitmap(ext2fs_block_bitmap bitmap)
{
ext2fs_free_generic_bmap(bitmap);
@@ -82,6 +87,39 @@ errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs,
(ext2fs_generic_bitmap *) ret));
}
+errcode_t ext2fs_allocate_exclude_bitmap(ext2_filsys fs,
+ const char *descr,
+ ext2fs_exclude_bitmap *ret)
+{
+ __u32 start, end, real_end;
+
+ if (!EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP))
+ return 0;
+
+ EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
+
+ fs->write_bitmaps = ext2fs_write_bitmaps;
+
+ start = fs->super->s_first_data_block;
+ end = fs->super->s_blocks_count-1;
+ real_end = (EXT2_BLOCKS_PER_GROUP(fs->super)
+ * fs->group_desc_count)-1 + start;
+
+ if (fs->flags & EXT2_FLAG_64BITS)
+ return ext2fs_alloc_generic_bmap(fs,
+ EXT2_ET_MAGIC_EXCLUDE_BITMAP64,
+ EXT2FS_BMAP64_BITARRAY,
+ start, end, real_end, descr, ret);
+
+ if ((end > ~0U) || (real_end > ~0U))
+ return EXT2_ET_CANT_USE_LEGACY_BITMAPS;
+
+ return ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_EXCLUDE_BITMAP, fs,
+ start, end, real_end,
+ descr, 0, ret);
+}
+
errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
const char *descr,
ext2fs_block_bitmap *ret)
@@ -268,6 +306,38 @@ errcode_t ext2fs_get_inode_bitmap_range(ext2fs_inode_bitmap bmap,
start, num, out));
}
+errcode_t ext2fs_set_exclude_bitmap_range(ext2fs_exclude_bitmap bmap,
+ blk_t start, unsigned int num,
+ void *in)
+{
+ return ext2fs_set_generic_bitmap_range(bmap,
+ EXT2_ET_MAGIC_EXCLUDE_BITMAP,
+ start, num, in);
+}
+
+errcode_t ext2fs_set_exclude_bitmap_range2(ext2fs_exclude_bitmap bmap,
+ blk64_t start, size_t num,
+ void *in)
+{
+ return ext2fs_set_generic_bmap_range(bmap, start, num, in);
+}
+
+errcode_t ext2fs_get_exclude_bitmap_range(ext2fs_exclude_bitmap bmap,
+ blk_t start, unsigned int num,
+ void *out)
+{
+ return ext2fs_get_generic_bitmap_range(bmap,
+ EXT2_ET_MAGIC_EXCLUDE_BITMAP,
+ start, num, out);
+}
+
+errcode_t ext2fs_get_exclude_bitmap_range2(ext2fs_exclude_bitmap bmap,
+ blk64_t start, size_t num,
+ void *out)
+{
+ return ext2fs_get_generic_bmap_range(bmap, start, num, out);
+}
+
errcode_t ext2fs_get_inode_bitmap_range2(ext2fs_inode_bitmap bmap,
__u64 start, size_t num,
void *out)
diff --git a/lib/ext2fs/blknum.c b/lib/ext2fs/blknum.c
index fd203b4..17df8c7 100644
--- a/lib/ext2fs/blknum.c
+++ b/lib/ext2fs/blknum.c
@@ -230,6 +230,33 @@ void ext2fs_block_bitmap_loc_set(ext2_filsys fs, dgrp_t group, blk64_t blk)
}
/*
+ * Return the exclude bitmap block of a group
+ */
+blk64_t ext2fs_exclude_bitmap_loc(ext2_filsys fs, dgrp_t group)
+{
+ struct ext4_group_desc *gdp;
+
+ gdp = ext4fs_group_desc(fs, fs->group_desc, group);
+ return gdp->bg_exclude_bitmap_lo |
+ (fs->super->s_feature_incompat
+ & EXT4_FEATURE_INCOMPAT_64BIT ?
+ (__u64)gdp->bg_exclude_bitmap_hi << 32 : 0);
+}
+
+/*
+ * Set the exclude bitmap block of a group
+ */
+void ext2fs_exclude_bitmap_loc_set(ext2_filsys fs, dgrp_t group, blk64_t blk)
+{
+ struct ext4_group_desc *gdp;
+
+ gdp = ext4fs_group_desc(fs, fs->group_desc, group);
+ gdp->bg_exclude_bitmap_lo = blk;
+ if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT)
+ gdp->bg_exclude_bitmap_hi = (__u64) blk >> 32;
+}
+
+/*
* Return the inode bitmap block of a group
*/
blk64_t ext2fs_inode_bitmap_loc(ext2_filsys fs, dgrp_t group)
diff --git a/lib/ext2fs/bmap64.h b/lib/ext2fs/bmap64.h
index 3056544..d1baef2 100644
--- a/lib/ext2fs/bmap64.h
+++ b/lib/ext2fs/bmap64.h
@@ -25,11 +25,13 @@ struct ext2fs_struct_generic_bitmap {
#define EXT2FS_IS_32_BITMAP(bmap) \
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
+ ((bmap)->magic == EXT2_ET_MAGIC_EXCLUDE_BITMAP) || \
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP))
#define EXT2FS_IS_64_BITMAP(bmap) \
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP64) || \
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP64) || \
+ ((bmap)->magic == EXT2_ET_MAGIC_EXCLUDE_BITMAP64) || \
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP64))
struct ext2_bitmap_ops {
diff --git a/lib/ext2fs/csum.c b/lib/ext2fs/csum.c
index 596923e..d6158e1 100644
--- a/lib/ext2fs/csum.c
+++ b/lib/ext2fs/csum.c
@@ -229,8 +229,9 @@ int main(int argc, char **argv)
for (i=0; i < fs->group_desc_count; i++) {
ext2fs_block_bitmap_loc_set(fs, i, 124);
- ext2fs_inode_bitmap_loc_set(fs, i, 125);
- ext2fs_inode_table_loc_set(fs, i, 126);
+ ext2fs_exclude_bitmap_loc_set(fs, i, 125);
+ ext2fs_inode_bitmap_loc_set(fs, i, 126);
+ ext2fs_inode_table_loc_set(fs, i, 127);
ext2fs_bg_free_blocks_count_set(fs, i, 31119);
ext2fs_bg_free_inodes_count_set(fs, i, 15701);
ext2fs_bg_used_dirs_count_set(fs, i, 2);
diff --git a/lib/ext2fs/dupfs.c b/lib/ext2fs/dupfs.c
index 64d3124..e7c00c1 100644
--- a/lib/ext2fs/dupfs.c
+++ b/lib/ext2fs/dupfs.c
@@ -77,6 +77,11 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
if (retval)
goto errout;
}
+ if (src->exclude_map) {
+ retval = ext2fs_copy_bitmap(src->exclude_map, &fs->exclude_map);
+ if (retval)
+ goto errout;
+ }
if (src->badblocks) {
retval = ext2fs_badblocks_copy(src->badblocks, &fs->badblocks);
if (retval)
diff --git a/lib/ext2fs/ext2_err.et.in b/lib/ext2fs/ext2_err.et.in
index e759b6f..c49f0d0 100644
--- a/lib/ext2fs/ext2_err.et.in
+++ b/lib/ext2fs/ext2_err.et.in
@@ -38,6 +38,9 @@ ec EXT2_ET_MAGIC_BLOCK_BITMAP,
ec EXT2_ET_MAGIC_INODE_BITMAP,
"Wrong magic number for inode_bitmap structure"
+ec EXT2_ET_MAGIC_EXCLUDE_BITMAP,
+ "Wrong magic number for snapshot_bitmap structure"
+
ec EXT2_ET_MAGIC_GENERIC_BITMAP,
"Wrong magic number for generic_bitmap structure"
@@ -101,6 +104,12 @@ ec EXT2_ET_BLOCK_BITMAP_WRITE,
ec EXT2_ET_BLOCK_BITMAP_READ,
"Can't read an block bitmap"
+ec EXT2_ET_EXCLUDE_BITMAP_WRITE,
+ "Can't write an snapshot bitmap"
+
+ec EXT2_ET_EXCLUDE_BITMAP_READ,
+ "Can't read an snapshot bitmap"
+
ec EXT2_ET_INODE_TABLE_WRITE,
"Can't write an inode table"
@@ -344,6 +353,9 @@ ec EXT2_ET_MAGIC_BLOCK_BITMAP64,
ec EXT2_ET_MAGIC_INODE_BITMAP64,
"Wrong magic number for 64-bit inode bitmap"
+ec EXT2_ET_MAGIC_EXCLUDE_BITMAP64,
+ "Wrong magic number for 64-bit exclude bitmap"
+
ec EXT2_ET_MAGIC_RESERVED_13,
"Wrong magic number --- RESERVED_13"
@@ -443,4 +455,13 @@ ec EXT2_ET_MMP_CHANGE_ABORT,
ec EXT2_ET_MMP_OPEN_DIRECT,
"MMP: open with O_DIRECT failed"
+ec EXT2_ET_BAD_EXCLUDE_TEST,
+ "Illegal block number passed to ext2fs_test_exclude_bitmap"
+
+ec EXT2_ET_BAD_EXCLUDE_MARK,
+ "Illegal block number passed to ext2fs_mark_exclude_bitmap"
+
+ec EXT2_ET_BAD_EXCLUDE_UNMARK,
+ "Illegal block number passed to ext2fs_unmark_exclude_bitmap"
+
end
diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
index 0f8cde8..a1e29d0 100644
--- a/lib/ext2fs/ext2_fs.h
+++ b/lib/ext2fs/ext2_fs.h
@@ -194,6 +194,7 @@ struct ext4_group_desc
#define EXT2_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not initialized */
#define EXT2_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not initialized */
#define EXT2_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */
+#define EXT2_BG_EXCLUDE_UNINIT 0x0008 /* Exclude bitmap not initialized */
/*
* Data structures used by the directory indexing feature
@@ -724,6 +725,7 @@ struct ext2_super_block {
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
EXT4_FEATURE_INCOMPAT_MMP)
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
+ EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT|\
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 203d222..d1f0d98 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -113,7 +113,9 @@ typedef struct struct_ext2_filsys *ext2_filsys;
typedef struct ext2fs_struct_generic_bitmap *ext2fs_generic_bitmap;
typedef struct ext2fs_struct_generic_bitmap *ext2fs_inode_bitmap;
+typedef struct ext2fs_struct_generic_bitmap *ext2fs_exclude_bitmap;
typedef struct ext2fs_struct_generic_bitmap *ext2fs_block_bitmap;
+typedef struct ext2fs_struct_generic_bitmap *ext2fs_exclude_bitmap;
#define EXT2_FIRST_INODE(s) EXT2_FIRST_INO(s)
@@ -196,6 +198,7 @@ typedef struct ext2_file *ext2_file_t;
#define EXT2_FLAG_PRINT_PROGRESS 0x40000
#define EXT2_FLAG_DIRECT_IO 0x80000
#define EXT2_FLAG_SKIP_MMP 0x100000
+#define EXT2_FLAG_EB_DIRTY 0x200000
/*
* Special flag in the ext2 inode i_flag field that means that this is
@@ -225,6 +228,7 @@ struct struct_ext2_filsys {
unsigned int inode_blocks_per_group;
ext2fs_inode_bitmap inode_map;
ext2fs_block_bitmap block_map;
+ ext2fs_exclude_bitmap exclude_map;
/* XXX FIXME-64: not 64-bit safe, but not used? */
errcode_t (*get_blocks)(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
errcode_t (*check_directory)(ext2_filsys fs, ext2_ino_t ino);
@@ -543,6 +547,7 @@ typedef struct ext2_icount *ext2_icount_t;
#define EXT2_LIB_FEATURE_COMPAT_SUPP (EXT2_FEATURE_COMPAT_DIR_PREALLOC|\
EXT2_FEATURE_COMPAT_IMAGIC_INODES|\
EXT3_FEATURE_COMPAT_HAS_JOURNAL|\
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP|\
EXT2_FEATURE_COMPAT_RESIZE_INODE|\
EXT2_FEATURE_COMPAT_DIR_INDEX|\
EXT2_FEATURE_COMPAT_EXT_ATTR)
@@ -721,8 +726,10 @@ extern errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src,
ext2fs_generic_bitmap *dest);
extern errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs);
extern errcode_t ext2fs_write_block_bitmap (ext2_filsys fs);
+extern errcode_t ext2fs_write_exclude_bitmap (ext2_filsys fs);
extern errcode_t ext2fs_read_inode_bitmap (ext2_filsys fs);
extern errcode_t ext2fs_read_block_bitmap(ext2_filsys fs);
+extern errcode_t ext2fs_read_exclude_bitmap (ext2_filsys fs);
extern errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs,
const char *descr,
ext2fs_block_bitmap *ret);
@@ -813,6 +820,9 @@ extern struct ext2_group_desc *ext2fs_group_desc(ext2_filsys fs,
extern blk64_t ext2fs_block_bitmap_loc(ext2_filsys fs, dgrp_t group);
extern void ext2fs_block_bitmap_loc_set(ext2_filsys fs, dgrp_t group,
blk64_t blk);
+extern blk64_t ext2fs_exclude_bitmap_loc(ext2_filsys fs, dgrp_t group);
+extern void ext2fs_block_exclude_loc_set(ext2_filsys fs, dgrp_t group,
+ blk64_t blk);
extern blk64_t ext2fs_inode_bitmap_loc(ext2_filsys fs, dgrp_t group);
extern void ext2fs_inode_bitmap_loc_set(ext2_filsys fs, dgrp_t group,
blk64_t blk);
@@ -1619,6 +1629,16 @@ _INLINE_ void ext2fs_mark_bb_dirty(ext2_filsys fs)
}
/*
+ * Mark the exclude bitmap as dirty
+ */
+_INLINE_ void ext2fs_mark_eb_dirty(ext2_filsys fs)
+{
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP))
+ fs->flags |= EXT2_FLAG_EB_DIRTY | EXT2_FLAG_CHANGED;
+}
+
+/*
* Check to see if a filesystem's inode bitmap is dirty
*/
_INLINE_ int ext2fs_test_ib_dirty(ext2_filsys fs)
@@ -1635,6 +1655,14 @@ _INLINE_ int ext2fs_test_bb_dirty(ext2_filsys fs)
}
/*
+ * Check to see if a filesystem's exclude bitmap is dirty
+ */
+_INLINE_ int ext2fs_test_eb_dirty(ext2_filsys fs)
+{
+ return fs->flags & EXT2_FLAG_EB_DIRTY;
+}
+
+/*
* Return the group # of a block
*/
_INLINE_ int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk)
diff --git a/lib/ext2fs/freefs.c b/lib/ext2fs/freefs.c
index 28c4132..488f077 100644
--- a/lib/ext2fs/freefs.c
+++ b/lib/ext2fs/freefs.c
@@ -43,6 +43,8 @@ void ext2fs_free(ext2_filsys fs)
ext2fs_free_block_bitmap(fs->block_map);
if (fs->inode_map)
ext2fs_free_inode_bitmap(fs->inode_map);
+ if (fs->exclude_map)
+ ext2fs_free_exclude_bitmap(fs->exclude_map);
if (fs->badblocks)
ext2fs_badblocks_list_free(fs->badblocks);
diff --git a/lib/ext2fs/gen_bitmap.c b/lib/ext2fs/gen_bitmap.c
index 6679bff..0285c33 100644
--- a/lib/ext2fs/gen_bitmap.c
+++ b/lib/ext2fs/gen_bitmap.c
@@ -42,11 +42,13 @@ struct ext2fs_struct_generic_bitmap {
#define EXT2FS_IS_32_BITMAP(bmap) \
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) || \
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP) || \
+ ((bmap)->magic == EXT2_ET_MAGIC_EXCLUDE_BITMAP) || \
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP))
#define EXT2FS_IS_64_BITMAP(bmap) \
(((bmap)->magic == EXT2_ET_MAGIC_GENERIC_BITMAP64) || \
((bmap)->magic == EXT2_ET_MAGIC_BLOCK_BITMAP64) || \
+ ((bmap)->magic == EXT2_ET_MAGIC_EXCLUDE_BITMAP64) || \
((bmap)->magic == EXT2_ET_MAGIC_INODE_BITMAP64))
/*
@@ -69,6 +71,7 @@ static errcode_t check_magic(ext2fs_generic_bitmap bitmap)
{
if (!bitmap || !((bitmap->magic == EXT2_ET_MAGIC_GENERIC_BITMAP) ||
(bitmap->magic == EXT2_ET_MAGIC_INODE_BITMAP) ||
+ (bitmap->magic == EXT2_ET_MAGIC_EXCLUDE_BITMAP) ||
(bitmap->magic == EXT2_ET_MAGIC_BLOCK_BITMAP)))
return EXT2_ET_MAGIC_GENERIC_BITMAP;
return 0;
@@ -100,6 +103,9 @@ errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs,
case EXT2_ET_MAGIC_BLOCK_BITMAP:
bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
break;
+ case EXT2_ET_MAGIC_EXCLUDE_BITMAP:
+ bitmap->base_error_code = EXT2_ET_BAD_EXCLUDE_MARK;
+ break;
default:
bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
}
@@ -517,6 +523,19 @@ int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
bitmap, block, num);
}
+int ext2fs_test_exlucde_bitmap_range(ext2fs_exclude_bitmap bitmap,
+ blk_t block, int num)
+{
+ EXT2_CHECK_MAGIC(bitmap, EXT2_ET_MAGIC_EXCLUDE_BITMAP);
+ if ((block < bitmap->start) || (block+num-1 > bitmap->real_end)) {
+ ext2fs_warn_bitmap(EXT2_ET_BAD_EXCLUDE_TEST,
+ block, bitmap->description);
+ return 0;
+ }
+ return ext2fs_test_clear_generic_bitmap_range((ext2fs_generic_bitmap)
+ bitmap, block, num);
+}
+
int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
ino_t inode, int num)
{
@@ -558,3 +577,32 @@ void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
ext2fs_fast_clear_bit(block + i - bitmap->start,
bitmap->bitmap);
}
+
+void ext2fs_mark_exclude_bitmap_range(ext2fs_exclude_bitmap bitmap,
+ blk_t block, int num)
+{
+ int i;
+
+ if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
+ ext2fs_warn_bitmap(EXT2_ET_BAD_EXCLUDE_MARK, block,
+ bitmap->description);
+ return;
+ }
+ for (i = 0; i < num; i++)
+ ext2fs_fast_set_bit(block + i - bitmap->start, bitmap->bitmap);
+}
+
+void ext2fs_unmark_exclude_bitmap_range(ext2fs_exclude_bitmap bitmap,
+ blk_t block, int num)
+{
+ int i;
+
+ if ((block < bitmap->start) || (block+num-1 > bitmap->end)) {
+ ext2fs_warn_bitmap(EXT2_ET_BAD_EXCLUDE_UNMARK, block,
+ bitmap->description);
+ return;
+ }
+ for (i = 0; i < num; i++)
+ ext2fs_fast_clear_bit(block + i - bitmap->start,
+ bitmap->bitmap);
+}
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index 9dbbf9f..abceb0f 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -117,6 +117,9 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
bitmap->cluster_bits = fs->cluster_ratio_bits;
break;
+ case EXT2_ET_MAGIC_EXCLUDE_BITMAP64:
+ bitmap->base_error_code = EXT2_ET_BAD_EXCLUDE_MARK;
+ break;
default:
bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
}
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index 47f0b1c..0dc8852 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -97,6 +97,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
int rsv_gdt;
int csum_flag;
int bigalloc_flag;
+ int exclude_flag;
int io_flags;
char *buf = 0;
char c;
@@ -407,6 +408,17 @@ ipg_retry:
if (retval)
goto cleanup;
+ exclude_flag = EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP);
+ if (exclude_flag) {
+ strcpy(buf, "exclude bitmap for ");
+ strcat(buf, fs->device_name);
+ retval = ext2fs_allocate_exclude_bitmap(fs, buf,
+ &fs->exclude_map);
+ if (retval)
+ goto cleanup;
+ }
+
strcpy(buf, "inode bitmap for ");
strcat(buf, fs->device_name);
retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map);
@@ -445,6 +457,9 @@ ipg_retry:
if (i != fs->group_desc_count - 1)
ext2fs_bg_flags_set(fs, i,
EXT2_BG_BLOCK_UNINIT);
+ if (exclude_flag)
+ ext2fs_bg_flags_set(fs, i,
+ EXT2_BG_EXCLUDE_UNINIT);
ext2fs_bg_flags_set(fs, i, EXT2_BG_INODE_UNINIT);
numblocks = super->s_inodes_per_group;
if (i == 0)
@@ -473,6 +488,7 @@ ipg_retry:
ext2fs_mark_super_dirty(fs);
ext2fs_mark_bb_dirty(fs);
+ ext2fs_mark_eb_dirty(fs);
ext2fs_mark_ib_dirty(fs);
io_channel_set_blksize(fs->io, fs->blocksize);
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index 0cefe3f..a047d0d 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -376,6 +376,8 @@ errcode_t ext2fs_open2(const char *name, const char *io_options,
for (group = 0; group < fs->group_desc_count; group++) {
ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, group,
+ EXT2_BG_EXCLUDE_UNINIT);
ext2fs_bg_flags_clear(fs, group, EXT2_BG_INODE_UNINIT);
ext2fs_bg_itable_unused_set(fs, group, 0);
}
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 1d5f7b2..3126733 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -28,17 +28,21 @@
#include "ext2fs.h"
#include "e2image.h"
-static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
+static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block,
+ int do_exclude)
{
dgrp_t i;
unsigned int j;
int block_nbytes, inode_nbytes;
unsigned int nbits;
errcode_t retval;
- char *block_buf = NULL, *inode_buf = NULL;
+ char *block_buf = NULL, *inode_buf = NULL,
+ *exclude_buf = NULL;
int csum_flag = 0;
blk64_t blk;
blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block);
+ blk64_t exclude_itr =
+ EXT2FS_B2C(fs, fs->super->s_first_data_block);
ext2_ino_t ino_itr = 1;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
@@ -46,6 +50,10 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
if (!(fs->flags & EXT2_FLAG_RW))
return EXT2_ET_RO_FILSYS;
+ if (!EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP))
+ do_exclude = 0;
+
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
csum_flag = 1;
@@ -59,6 +67,14 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
goto errout;
memset(block_buf, 0xff, fs->blocksize);
}
+ if (do_exclude) {
+ block_nbytes = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
+ retval = ext2fs_get_memalign(fs->blocksize, fs->blocksize,
+ &exclude_buf);
+ if (retval)
+ return retval;
+ memset(exclude_buf, 0x0, fs->blocksize);
+ }
if (do_inode) {
inode_nbytes = (size_t)
((EXT2_INODES_PER_GROUP(fs->super)+7) / 8);
@@ -104,6 +120,26 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
skip_this_block_bitmap:
blk_itr += block_nbytes << 3;
skip_block_bitmap:
+ if (!do_exclude)
+ goto skip_exclude_bitmap;
+ if (csum_flag && ext2fs_bg_flags_test(fs, i, EXT2_BG_EXCLUDE_UNINIT)
+ )
+ goto skip_this_exclude_bitmap;
+
+ retval = ext2fs_get_block_bitmap_range2(fs->exclude_map,
+ exclude_itr, block_nbytes << 3, exclude_buf);
+ if (retval)
+ goto errout;
+ blk = ext2fs_exclude_bitmap_loc(fs, i);
+ if (blk) {
+ retval = io_channel_write_blk64(fs->io, blk, 1,
+ exclude_buf);
+ if (retval)
+ return EXT2_ET_EXCLUDE_BITMAP_WRITE;
+ }
+ skip_this_exclude_bitmap:
+ exclude_itr += block_nbytes << 3;
+ skip_exclude_bitmap:
if (!do_inode)
continue;
@@ -126,7 +162,7 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
goto errout;
}
}
- skip_this_inode_bitmap:
+skip_this_inode_bitmap:
ino_itr += inode_nbytes << 3;
}
@@ -134,6 +170,10 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block)
fs->flags &= ~EXT2_FLAG_BB_DIRTY;
ext2fs_free_mem(&block_buf);
}
+ if (do_exclude) {
+ fs->flags &= ~EXT2_FLAG_EB_DIRTY;
+ ext2fs_free_mem(&exclude_buf);
+ }
if (do_inode) {
fs->flags &= ~EXT2_FLAG_IB_DIRTY;
ext2fs_free_mem(&inode_buf);
@@ -147,10 +187,11 @@ errout:
return retval;
}
-static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
+static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block,
+ int do_exclude)
{
dgrp_t i;
- char *block_bitmap = 0, *inode_bitmap = 0;
+ char *block_bitmap = 0, *inode_bitmap = 0, *exclude_bitmap = 0;
char *buf;
errcode_t retval;
int block_nbytes = EXT2_CLUSTERS_PER_GROUP(fs->super) / 8;
@@ -168,6 +209,10 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
fs->write_bitmaps = ext2fs_write_bitmaps;
+ if (!EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP))
+ do_exclude = 0;
+
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
csum_flag = 1;
@@ -192,7 +237,25 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
if (retval)
goto cleanup;
- } else
+ }
+ if (do_exclude) {
+ if (fs->exclude_map)
+ ext2fs_free_block_bitmap(fs->exclude_map);
+ strcpy(buf, "exclude bitmap for ");
+ strcat(buf, fs->device_name);
+ retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->exclude_map);
+ if (retval)
+ goto cleanup;
+ if (do_image)
+ retval = ext2fs_get_mem(fs->blocksize, &exclude_bitmap);
+ else
+ retval = ext2fs_get_memalign((unsigned) block_nbytes,
+ fs->blocksize,
+ &exclude_bitmap);
+ if (retval)
+ goto cleanup;
+ }
+ if (!do_block && !do_exclude)
block_nbytes = 0;
if (do_inode) {
if (fs->inode_map)
@@ -234,6 +297,11 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
blk_cnt = (blk64_t)EXT2_CLUSTERS_PER_GROUP(fs->super) *
fs->group_desc_count;
while (block_nbytes > 0) {
+ if (do_exclude) {
+ retval = EXT2_ET_EXCLUDE_BITMAP_READ;
+ goto cleanup;
+ }
+
retval = io_channel_read_blk64(fs->image_io, blk++,
1, block_bitmap);
if (retval)
@@ -273,8 +341,30 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
blk_itr, cnt, block_bitmap);
if (retval)
goto cleanup;
- blk_itr += block_nbytes << 3;
}
+ if (exclude_bitmap) {
+ blk = ext2fs_exclude_bitmap_loc(fs, i);
+ if (csum_flag &&
+ ext2fs_bg_flags_test(fs, i, EXT2_BG_EXCLUDE_UNINIT) &&
+ ext2fs_group_desc_csum_verify(fs, i))
+ blk = 0;
+ if (blk) {
+ retval = io_channel_read_blk64(fs->io, blk,
+ -block_nbytes, exclude_bitmap);
+ if (retval) {
+ retval = EXT2_ET_EXCLUDE_BITMAP_READ;
+ goto cleanup;
+ }
+ } else
+ memset(exclude_bitmap, 0, block_nbytes);
+ cnt = block_nbytes << 3;
+ retval = ext2fs_set_block_bitmap_range2(fs->exclude_map,
+ blk_itr, cnt, exclude_bitmap);
+ if (retval)
+ goto cleanup;
+ }
+ if (block_nbytes)
+ blk_itr += block_nbytes << 3;
if (inode_bitmap) {
blk = ext2fs_inode_bitmap_loc(fs, i);
if (csum_flag &&
@@ -303,6 +393,8 @@ success_cleanup:
ext2fs_free_mem(&inode_bitmap);
if (block_bitmap)
ext2fs_free_mem(&block_bitmap);
+ if (exclude_bitmap)
+ ext2fs_free_mem(&exclude_bitmap);
return 0;
cleanup:
@@ -318,6 +410,8 @@ cleanup:
ext2fs_free_mem(&inode_bitmap);
if (block_bitmap)
ext2fs_free_mem(&block_bitmap);
+ if (exclude_bitmap)
+ ext2fs_free_mem(&exclude_bitmap);
if (buf)
ext2fs_free_mem(&buf);
return retval;
@@ -325,39 +419,51 @@ cleanup:
errcode_t ext2fs_read_inode_bitmap(ext2_filsys fs)
{
- return read_bitmaps(fs, 1, 0);
+ return read_bitmaps(fs, 1, 0, 0);
}
errcode_t ext2fs_read_block_bitmap(ext2_filsys fs)
{
- return read_bitmaps(fs, 0, 1);
+ return read_bitmaps(fs, 0, 1, 0);
+}
+
+errcode_t ext2fs_read_exclude_bitmap (ext2_filsys fs)
+{
+ return read_bitmaps(fs, 0, 0, 1);
}
errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs)
{
- return write_bitmaps(fs, 1, 0);
+ return write_bitmaps(fs, 1, 0, 0);
}
errcode_t ext2fs_write_block_bitmap (ext2_filsys fs)
{
- return write_bitmaps(fs, 0, 1);
+ return write_bitmaps(fs, 0, 1, 0);
+}
+
+errcode_t ext2fs_write_exclude_bitmap (ext2_filsys fs)
+{
+ return write_bitmaps(fs, 0, 0, 1);
}
errcode_t ext2fs_read_bitmaps(ext2_filsys fs)
{
- if (fs->inode_map && fs->block_map)
+ if (fs->inode_map && fs->block_map && fs->exclude_map)
return 0;
- return read_bitmaps(fs, !fs->inode_map, !fs->block_map);
+ return read_bitmaps(fs, !fs->inode_map, !fs->block_map,
+ !fs->exclude_map);
}
errcode_t ext2fs_write_bitmaps(ext2_filsys fs)
{
int do_inode = fs->inode_map && ext2fs_test_ib_dirty(fs);
int do_block = fs->block_map && ext2fs_test_bb_dirty(fs);
+ int do_exclude = fs->exclude_map && ext2fs_test_eb_dirty(fs);
- if (!do_inode && !do_block)
+ if (!do_inode && !do_block && !do_exclude)
return 0;
- return write_bitmaps(fs, do_inode, do_block);
+ return write_bitmaps(fs, do_inode, do_block, do_exclude);
}
diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c
index 7962472..07ba1cd 100644
--- a/lib/ext2fs/swapfs.c
+++ b/lib/ext2fs/swapfs.c
@@ -105,6 +105,7 @@ void ext2fs_swap_group_desc2(ext2_filsys fs, struct ext2_group_desc *gdp)
{
/* Do the 32-bit parts first */
gdp->bg_block_bitmap = ext2fs_swab32(gdp->bg_block_bitmap);
+ gdp->bg_exclude_bitmap = ext2fs_swab32(gdp->bg_exclude_bitmap);
gdp->bg_inode_bitmap = ext2fs_swab32(gdp->bg_inode_bitmap);
gdp->bg_inode_table = ext2fs_swab32(gdp->bg_inode_table);
gdp->bg_free_blocks_count = ext2fs_swab16(gdp->bg_free_blocks_count);
@@ -126,6 +127,7 @@ void ext2fs_swap_group_desc2(ext2_filsys fs, struct ext2_group_desc *gdp)
/* Swap the 64-bit parts */
struct ext4_group_desc *gdp4 = (struct ext4_group_desc *) gdp;
gdp4->bg_block_bitmap_hi = ext2fs_swab32(gdp4->bg_block_bitmap_hi);
+ gdp4->bg_exclude_bitmap_hi = ext2fs_swab32(gdp4->bg_exclude_bitmap_hi);
gdp4->bg_inode_bitmap_hi = ext2fs_swab32(gdp4->bg_inode_bitmap_hi);
gdp4->bg_inode_table_hi = ext2fs_swab32(gdp4->bg_inode_table_hi);
gdp4->bg_free_blocks_count_hi =
--
1.7.5.1
^ permalink raw reply related
* [PATCH 2/8] e2fsprogs: add exclude bitmap support in mkfs
From: Yongqiang Yang @ 2011-10-23 7:21 UTC (permalink / raw)
To: linux-ext4; +Cc: amir73il, Yongqiang Yang
In-Reply-To: <1319354488-6050-1-git-send-email-xiaoqiangnk@gmail.com>
Exclude bitmap is needed by ext4 snapshot. This patch adds
exclude bitmap support in mkfs.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
misc/mke2fs.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 3dcb3b7..2dc28e7 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -828,6 +828,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
static __u32 ok_features[3] = {
/* Compat */
EXT3_FEATURE_COMPAT_HAS_JOURNAL |
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP |
EXT2_FEATURE_COMPAT_RESIZE_INODE |
EXT2_FEATURE_COMPAT_DIR_INDEX |
EXT2_FEATURE_COMPAT_EXT_ATTR,
--
1.7.5.1
^ permalink raw reply related
* [PATCH 3/8] e2fsprogs: check the exclude bitmap
From: Yongqiang Yang @ 2011-10-23 7:21 UTC (permalink / raw)
To: linux-ext4; +Cc: amir73il, Yongqiang Yang
In-Reply-To: <1319354488-6050-1-git-send-email-xiaoqiangnk@gmail.com>
From: Amir Goldstein <amir73il@users.sf.net>
Excluding snapshot blocks from COW is done by setting their bit in
the exclude bitmap. There is one exclude bitmap block per block group.
Fsck checks that all (and only) snapshot file blocks are excluded.
Signed-off-by: Amir Goldstein <amir73il@users.sf.net>
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
e2fsck/e2fsck.h | 1 +
e2fsck/pass1.c | 17 ++++++-
e2fsck/pass5.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
e2fsck/problem.c | 31 ++++++++++++
e2fsck/problem.h | 19 +++++++
5 files changed, 211 insertions(+), 1 deletions(-)
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index d225d89..44909c3 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -241,6 +241,7 @@ struct e2fsck_struct {
ext2fs_inode_bitmap inode_reg_map; /* Inodes which are regular files*/
ext2fs_block_bitmap block_found_map; /* Blocks which are in use */
+ ext2fs_block_bitmap block_excluded_map; /* Blocks which are excluded */
ext2fs_block_bitmap block_dup_map; /* Blks referenced more than once */
ext2fs_block_bitmap block_ea_map; /* Blocks which are used by EA's */
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index f45831f..3587dff 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -80,7 +80,7 @@ static void adjust_extattr_refcount(e2fsck_t ctx, ext2_refcount_t refcount,
struct process_block_struct {
ext2_ino_t ino;
unsigned is_dir:1, is_reg:1, clear:1, suppress:1,
- fragmented:1, compressed:1, bbcheck:1;
+ fragmented:1, compressed:1, bbcheck:1, snapfile:1;
blk64_t num_blocks;
blk64_t max_blocks;
e2_blkcnt_t last_block;
@@ -627,6 +627,16 @@ void e2fsck_pass1(e2fsck_t ctx)
ctx->flags |= E2F_FLAG_ABORT;
return;
}
+ if (sb->s_feature_compat & EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP)
+ pctx.errcode = ext2fs_allocate_block_bitmap(fs,
+ _("excluded block map"),
+ &ctx->block_excluded_map);
+ if (pctx.errcode) {
+ pctx.num = 1;
+ fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, &pctx);
+ ctx->flags |= E2F_FLAG_ABORT;
+ return;
+ }
e2fsck_setup_tdb_icount(ctx, 0, &ctx->inode_link_info);
if (!ctx->inode_link_info)
pctx.errcode = ext2fs_create_icount2(fs, 0, 0, 0,
@@ -1940,6 +1950,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
pb.previous_block = 0;
pb.is_dir = LINUX_S_ISDIR(inode->i_mode);
pb.is_reg = LINUX_S_ISREG(inode->i_mode);
+ pb.snapfile = (pb.is_reg && (inode->i_flags & EXT4_SNAPFILE_FL));
pb.max_blocks = 1 << (31 - fs->super->s_log_block_size);
pb.inode = inode;
pb.pctx = pctx;
@@ -2296,6 +2307,10 @@ static int process_block(ext2_filsys fs,
(blk & EXT2FS_CLUSTER_MASK(ctx->fs)) ==
(blockcnt & EXT2FS_CLUSTER_MASK(ctx->fs)))) {
mark_block_used(ctx, blk);
+ /* mark snapshot file blocks excluded */
+ if (p->snapfile && ctx->block_excluded_map)
+ ext2fs_fast_mark_block_bitmap2(ctx->block_excluded_map,
+ blk);
p->num_blocks++;
}
if (blockcnt >= 0)
diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index a60e84a..0dda1b3 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -24,6 +24,7 @@
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
static void check_block_bitmaps(e2fsck_t ctx);
+static void check_exclude_bitmaps(e2fsck_t ctx);
static void check_inode_bitmaps(e2fsck_t ctx);
static void check_inode_end(e2fsck_t ctx);
static void check_block_end(e2fsck_t ctx);
@@ -54,6 +55,9 @@ void e2fsck_pass5(e2fsck_t ctx)
check_block_bitmaps(ctx);
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
+ check_exclude_bitmaps(ctx);
+ if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
+ return;
check_inode_bitmaps(ctx);
if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
return;
@@ -70,6 +74,9 @@ void e2fsck_pass5(e2fsck_t ctx)
ctx->inode_dir_map = 0;
ext2fs_free_block_bitmap(ctx->block_found_map);
ctx->block_found_map = 0;
+ if (ctx->block_excluded_map)
+ ext2fs_free_block_bitmap(ctx->block_excluded_map);
+ ctx->block_excluded_map = 0;
print_resource_track(ctx, _("Pass 5"), &rtrack, ctx->fs->io);
}
@@ -112,6 +119,18 @@ static void print_bitmap_problem(e2fsck_t ctx, int problem,
else
problem = PR_5_BLOCK_RANGE_USED;
break;
+ case PR_5_BLOCK_NOTEXCLUDED:
+ if (pctx->blk == pctx->blk2)
+ pctx->blk2 = 0;
+ else
+ problem = PR_5_BLOCK_RANGE_NOTEXCLUDED;
+ break;
+ case PR_5_BLOCK_EXCLUDED:
+ if (pctx->blk == pctx->blk2)
+ pctx->blk2 = 0;
+ else
+ problem = PR_5_BLOCK_RANGE_EXCLUDED;
+ break;
case PR_5_INODE_UNUSED:
if (pctx->ino == pctx->ino2)
pctx->ino2 = 0;
@@ -416,6 +435,131 @@ errout:
ext2fs_free_mem(&free_array);
}
+static void check_exclude_bitmaps(e2fsck_t ctx)
+{
+ ext2_filsys fs = ctx->fs;
+ blk64_t i;
+ int group = 0;
+ int blocks = 0;
+ int actual, bitmap;
+ struct problem_context pctx;
+ int problem, save_problem, fixit, had_problem;
+ errcode_t retval;
+ int csum_flag;
+ int skip_group = 0;
+
+ clear_problem_context(&pctx);
+
+ if (!(fs->super->s_feature_compat &
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP))
+ return;
+
+ csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
+redo_counts:
+ had_problem = 0;
+ save_problem = 0;
+ pctx.blk = pctx.blk2 = NO_BLK;
+ if (csum_flag &&
+ (ext2fs_bg_flags_test(fs, group, EXT2_BG_BLOCK_UNINIT)))
+ skip_group++;
+ for (i = fs->super->s_first_data_block;
+ i < ext2fs_blocks_count(fs->super);
+ i++) {
+ actual = ext2fs_fast_test_block_bitmap2(ctx->block_excluded_map, i);
+
+ if (skip_group) {
+ bitmap = 0;
+ actual = (actual != 0);
+ } else
+ bitmap = ext2fs_fast_test_block_bitmap2(fs->exclude_map, i);
+
+ if (actual == bitmap)
+ goto do_counts;
+
+ if (!actual && bitmap) {
+ /*
+ * Block not excluded, but marked in exclude bitmap.
+ */
+ problem = PR_5_BLOCK_NOTEXCLUDED;
+ } else {
+ /*
+ * Block excluded, but not marked in exclude bitmap.
+ */
+ problem = PR_5_BLOCK_EXCLUDED;
+
+ if (skip_group) {
+ struct problem_context pctx2;
+ pctx2.blk = i;
+ pctx2.group = group;
+ if (fix_problem(ctx, PR_5_BLOCK_UNINIT,&pctx2)){
+ ext2fs_bg_flags_clear(fs, group, EXT2_BG_BLOCK_UNINIT);
+ skip_group = 0;
+ }
+ }
+ }
+ if (pctx.blk == NO_BLK) {
+ pctx.blk = pctx.blk2 = i;
+ save_problem = problem;
+ } else {
+ if ((problem == save_problem) &&
+ (pctx.blk2 == i-1))
+ pctx.blk2++;
+ else {
+ print_bitmap_problem(ctx, save_problem, &pctx);
+ pctx.blk = pctx.blk2 = i;
+ save_problem = problem;
+ }
+ }
+ ctx->flags |= E2F_FLAG_PROG_SUPPRESS;
+ had_problem++;
+
+ do_counts:
+ blocks ++;
+ if ((blocks == fs->super->s_blocks_per_group) ||
+ (i == fs->super->s_blocks_count-1)) {
+ group ++;
+ blocks = 0;
+ skip_group = 0;
+ if (ctx->progress)
+ if ((ctx->progress)(ctx, 5, group,
+ fs->group_desc_count*2))
+ return;
+ if (csum_flag &&
+ (i != ext2fs_blocks_count(fs->super)-1) &&
+ ext2fs_bg_flags_test(fs, group,
+ EXT2_BG_BLOCK_UNINIT))
+ skip_group++;
+ }
+ }
+ if (pctx.blk != NO_BLK)
+ print_bitmap_problem(ctx, save_problem, &pctx);
+ if (had_problem)
+ fixit = end_problem_latch(ctx, PR_LATCH_XBITMAP);
+ else
+ fixit = -1;
+ ctx->flags &= ~E2F_FLAG_PROG_SUPPRESS;
+
+ if (fixit == 1) {
+ ext2fs_free_block_bitmap(fs->exclude_map);
+ retval = ext2fs_copy_bitmap(ctx->block_excluded_map,
+ &fs->exclude_map);
+ if (retval) {
+ clear_problem_context(&pctx);
+ fix_problem(ctx, PR_5_COPY_BBITMAP_ERROR, &pctx);
+ ctx->flags |= E2F_FLAG_ABORT;
+ return;
+ }
+ ext2fs_mark_eb_dirty(fs);
+ /* clear fix_exclude flag */
+ if (fs->super->s_flags & EXT2_FLAGS_FIX_EXCLUDE) {
+ fs->super->s_flags &= ~EXT2_FLAGS_FIX_EXCLUDE;
+ ext2fs_mark_super_dirty(fs);
+ }
+ } else if (fixit == 0)
+ ext2fs_unmark_valid(fs);
+}
+
static void check_inode_bitmaps(e2fsck_t ctx)
{
ext2_filsys fs = ctx->fs;
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index cf4a270..ad703c7 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1578,6 +1578,26 @@ static struct e2fsck_problem problem_table[] = {
"\n",
PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },
+ /* Exclude bitmap differences header */
+ { PR_5_EXCLUDE_BITMAP_HEADER,
+ N_("Exclude @B differences: "),
+ PROMPT_NONE, PR_PREEN_OK | PR_PREEN_NOMSG},
+
+ /* Block not excluded, but marked in exclude bitmap */
+ { PR_5_BLOCK_NOTEXCLUDED,
+ " -%b",
+ PROMPT_NONE, PR_LATCH_XBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
+
+ /* Block excluded, but not marked in exclude bitmap */
+ { PR_5_BLOCK_EXCLUDED,
+ " +%b",
+ PROMPT_NONE, PR_LATCH_XBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
+
+ /* Exclude bitmap differences end */
+ { PR_5_EXCLUDE_BITMAP_END,
+ "\n",
+ PROMPT_FIX, PR_PREEN_OK | PR_PREEN_NOMSG },
+
/* Inode bitmap differences header */
{ PR_5_INODE_BITMAP_HEADER,
N_("@i @B differences: "),
@@ -1654,6 +1674,16 @@ static struct e2fsck_problem problem_table[] = {
" +(%b--%c)",
PROMPT_NONE, PR_LATCH_BBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
+ /* Block range not excluded, but marked in exclude bitmap */
+ { PR_5_BLOCK_RANGE_NOTEXCLUDED,
+ " -(%b--%c)",
+ PROMPT_NONE, PR_LATCH_XBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
+
+ /* Block range excluded, but not marked in exclude bitmap */
+ { PR_5_BLOCK_RANGE_EXCLUDED,
+ " +(%b--%c)",
+ PROMPT_NONE, PR_LATCH_XBITMAP | PR_PREEN_OK | PR_PREEN_NOMSG },
+
/* Inode range not used, but marked in bitmap */
{ PR_5_INODE_RANGE_UNUSED,
" -(%i--%j)",
@@ -1695,6 +1725,7 @@ static struct latch_descr pr_latch_info[] = {
{ PR_LATCH_BBLOCK, PR_1_INODE_BBLOCK_LATCH, 0 },
{ PR_LATCH_IBITMAP, PR_5_INODE_BITMAP_HEADER, PR_5_INODE_BITMAP_END },
{ PR_LATCH_BBITMAP, PR_5_BLOCK_BITMAP_HEADER, PR_5_BLOCK_BITMAP_END },
+ { PR_LATCH_XBITMAP, PR_5_EXCLUDE_BITMAP_HEADER, PR_5_EXCLUDE_BITMAP_END },
{ PR_LATCH_RELOC, PR_0_RELOCATE_HINT, 0 },
{ PR_LATCH_DBLOCK, PR_1B_DUP_BLOCK_HEADER, PR_1B_DUP_BLOCK_END },
{ PR_LATCH_LOW_DTIME, PR_1_ORPHAN_LIST_REFUGEES, 0 },
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 17b0c10..3647f6e 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -39,6 +39,7 @@ struct problem_context {
#define PR_LATCH_TOOBIG 0x0080 /* Latch for file to big errors */
#define PR_LATCH_OPTIMIZE_DIR 0x0090 /* Latch for optimize directories */
#define PR_LATCH_BG_CHECKSUM 0x00A0 /* Latch for block group checksums */
+#define PR_LATCH_XBITMAP 0x00B0 /* Latch for pass 5 exclude bitmap proc. */
#define PR_LATCH(x) ((((x) & PR_LATCH_MASK) >> 4) - 1)
@@ -1010,6 +1011,24 @@ struct problem_context {
/* Inode in use but group is marked INODE_UNINIT */
#define PR_5_INODE_UNINIT 0x050019
+/* Exclude bitmap differences header */
+#define PR_5_EXCLUDE_BITMAP_HEADER 0x050100
+
+/* Block not excluded, but marked in exclude bitmap */
+#define PR_5_BLOCK_NOTEXCLUDED 0x050101
+
+/* Block excluded, but not marked in exclude bitmap */
+#define PR_5_BLOCK_EXCLUDED 0x050102
+
+/* Block range not excluded, but marked in exclude bitmap */
+#define PR_5_BLOCK_RANGE_NOTEXCLUDED 0x050103
+
+/* Block range excluded, but not marked in exclude bitmap */
+#define PR_5_BLOCK_RANGE_EXCLUDED 0x050104
+
+/* Exclude bitmap differences end */
+#define PR_5_EXCLUDE_BITMAP_END 0x050105
+
/*
* Post-Pass 5 errors
*/
--
1.7.5.1
^ permalink raw reply related
* [PATCH 4/8] e2fsprogs: add exclude bitmap support in e2fsck
From: Yongqiang Yang @ 2011-10-23 7:21 UTC (permalink / raw)
To: linux-ext4; +Cc: amir73il, Yongqiang Yang
In-Reply-To: <1319354488-6050-1-git-send-email-xiaoqiangnk@gmail.com>
Exclude bitmap is a compat feature needed by exy4 snapshot. This
patch add exclude bitmap support in e2fsck.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
e2fsck/e2fsck.h | 1 +
e2fsck/pass1.c | 35 +++++++++++++++++++++++++++++++++++
e2fsck/pass1b.c | 5 +++++
e2fsck/pass5.c | 3 +++
e2fsck/problem.h | 6 ++++++
e2fsck/super.c | 18 ++++++++++++++++++
e2fsck/util.c | 9 ++++++---
lib/ext2fs/check_desc.c | 14 ++++++++++++++
8 files changed, 88 insertions(+), 3 deletions(-)
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 44909c3..bd85683 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -260,6 +260,7 @@ struct e2fsck_struct {
*/
int *invalid_inode_bitmap_flag;
int *invalid_block_bitmap_flag;
+ int *invalid_exclude_bitmap_flag;
int *invalid_inode_table_flag;
int invalid_bitmaps; /* There are invalid bitmaps/itable */
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 3587dff..90eeff1 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -2462,6 +2462,15 @@ static int process_bad_block(ext2_filsys fs,
}
return 0;
}
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ blk == ext2fs_exclude_bitmap_loc(fs, i)) {
+ if (fix_problem(ctx, PR_1_BB_BAD_BLOCK, pctx)) {
+ ctx->invalid_exclude_bitmap_flag[i]++;
+ ctx->invalid_bitmaps++;
+ }
+ return 0;
+ }
if (blk == ext2fs_inode_bitmap_loc(fs, i)) {
if (fix_problem(ctx, PR_1_IB_BAD_BLOCK, pctx)) {
ctx->invalid_inode_bitmap_flag[i]++;
@@ -2613,6 +2622,13 @@ static void handle_fs_bad_blocks(e2fsck_t ctx)
1, &new_blk);
ext2fs_block_bitmap_loc_set(fs, i, new_blk);
}
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ ctx->invalid_exclude_bitmap_flag[i]) {
+ new_table_block(ctx, first_block, i,
+ _("exclude bitmap"), 1, &new_blk);
+ ext2fs_exclude_bitmap_loc_set(fs, i, new_blk);
+ }
if (ctx->invalid_inode_bitmap_flag[i]) {
new_blk = ext2fs_inode_bitmap_loc(fs, i);
new_table_block(ctx, first_block, i, _("inode bitmap"),
@@ -2691,6 +2707,25 @@ static void mark_table_blocks(e2fsck_t ctx)
}
/*
+ * Mark block used for the exclude bitmap
+ */
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ ext2fs_exclude_bitmap_loc(fs, i)) {
+ if (ext2fs_test_block_bitmap2(ctx->block_found_map,
+ ext2fs_exclude_bitmap_loc(fs, i))) {
+ pctx.blk = ext2fs_exclude_bitmap_loc(fs, i);
+ if (fix_problem(ctx, PR_1_EB_CONFLICT, &pctx)) {
+ ctx->invalid_exclude_bitmap_flag[i]++;
+ ctx->invalid_bitmaps++;
+ }
+ } else {
+ ext2fs_mark_block_bitmap2(ctx->block_found_map,
+ ext2fs_exclude_bitmap_loc(fs, i));
+ }
+
+ }
+ /*
* Mark block used for the inode bitmap
*/
if (ext2fs_inode_bitmap_loc(fs, i)) {
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index 5ff92c2..4994596 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -910,6 +910,11 @@ static int check_if_fs_block(e2fsck_t ctx, blk64_t test_block)
(test_block == ext2fs_inode_bitmap_loc(fs, i)))
return 1;
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ test_block == ext2fs_exclude_bitmap_loc(fs, i))
+ return 1;
+
first_block += fs->super->s_blocks_per_group;
}
return 0;
diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c
index 0dda1b3..416e325 100644
--- a/e2fsck/pass5.c
+++ b/e2fsck/pass5.c
@@ -257,6 +257,9 @@ redo_counts:
LE_CLSTR(i, old_desc_blk + old_desc_blocks-1)) ||
(new_desc_blk && EQ_CLSTR(i, new_desc_blk)) ||
EQ_CLSTR(i, ext2fs_block_bitmap_loc(fs, group)) ||
+ (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ (EQ_CLSTR(i, ext2fs_exclude_bitmap_loc(fs, group)))) ||
EQ_CLSTR(i, ext2fs_inode_bitmap_loc(fs, group)) ||
(GE_CLSTR(i, ext2fs_inode_table_loc(fs, group)) &&
LE_CLSTR(i, (ext2fs_inode_table_loc(fs, group) +
diff --git a/e2fsck/problem.h b/e2fsck/problem.h
index 3647f6e..f2b2663 100644
--- a/e2fsck/problem.h
+++ b/e2fsck/problem.h
@@ -243,6 +243,8 @@ struct problem_context {
/* Superblock has invalid MMP magic. */
#define PR_0_MMP_INVALID_MAGIC 0x000043
+/* Exclude bitmap not in group */
+#define PR_0_EB_NOT_GROUP 0x000104
/*
* Pass 1 errors
@@ -548,6 +550,10 @@ struct problem_context {
/* Quota inode is user visible */
#define PR_1_QUOTA_INODE_NOT_HIDDEN 0x010064
+/* Block bitmap conflicts with some other fs block */
+#define PR_1_EB_CONFLICT 0x010101
+
+
/*
* Pass 1b errors
*/
diff --git a/e2fsck/super.c b/e2fsck/super.c
index 36e7309..63fd218 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -604,6 +604,20 @@ void check_super_block(e2fsck_t ctx)
ctx->invalid_block_bitmap_flag[i]++;
ctx->invalid_bitmaps++;
}
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ ((ext2fs_exclude_bitmap_loc(fs, i) < first_block) ||
+ (ext2fs_exclude_bitmap_loc(fs, i) > last_block))) {
+ pctx.blk = ext2fs_exclude_bitmap_loc(fs, i);
+ if (fix_problem(ctx, PR_0_EB_NOT_GROUP, &pctx))
+ ext2fs_exclude_bitmap_loc_set(fs, i, 0);
+ }
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ ext2fs_exclude_bitmap_loc(fs, i) == 0) {
+ ctx->invalid_exclude_bitmap_flag[i]++;
+ ctx->invalid_bitmaps++;
+ }
if ((ext2fs_inode_bitmap_loc(fs, i) < first_block) ||
(ext2fs_inode_bitmap_loc(fs, i) > last_block)) {
pctx.blk = ext2fs_inode_bitmap_loc(fs, i);
@@ -637,6 +651,8 @@ void check_super_block(e2fsck_t ctx)
if (!ext2fs_group_desc_csum_verify(fs, i)) {
if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) {
ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, i,
+ EXT2_BG_EXCLUDE_UNINIT);
ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
ext2fs_bg_itable_unused_set(fs, i, 0);
should_be = 1;
@@ -646,10 +662,12 @@ void check_super_block(e2fsck_t ctx)
if (!csum_flag &&
(ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) ||
+ ext2fs_bg_flags_test(fs, i, EXT2_BG_EXCLUDE_UNINIT) ||
ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) ||
ext2fs_bg_itable_unused(fs, i) != 0)) {
if (fix_problem(ctx, PR_0_GDT_UNINIT, &pctx)) {
ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
+ ext2fs_bg_flags_clear(fs, i, EXT2_BG_EXCLUDE_UNINIT);
ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
ext2fs_bg_itable_unused_set(fs, i, 0);
should_be = 1;
diff --git a/e2fsck/util.c b/e2fsck/util.c
index 06daf12..45fa14c 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -226,7 +226,8 @@ void e2fsck_read_bitmaps(e2fsck_t ctx)
fatal_error(ctx, 0);
}
- old_op = ehandler_operation(_("reading inode and block bitmaps"));
+ old_op = ehandler_operation(_("reading inode, exclude and block "
+ "bitmaps"));
retval = ext2fs_read_bitmaps(fs);
ehandler_operation(old_op);
if (retval) {
@@ -243,12 +244,14 @@ void e2fsck_write_bitmaps(e2fsck_t ctx)
errcode_t retval;
const char *old_op;
- old_op = ehandler_operation(_("writing block and inode bitmaps"));
+ old_op = ehandler_operation(_("writing block, exclude "
+ "and inode bitmaps"));
retval = ext2fs_write_bitmaps(fs);
ehandler_operation(old_op);
if (retval) {
com_err(ctx->program_name, retval,
- _("while rewriting block and inode bitmaps for %s"),
+ _("while rewriting block, exclude "
+ "and inode bitmaps for %s"),
ctx->device_name);
fatal_error(ctx, 0);
}
diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c
index a6fcc45..881959c 100644
--- a/lib/ext2fs/check_desc.c
+++ b/lib/ext2fs/check_desc.c
@@ -68,6 +68,20 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
ext2fs_mark_block_bitmap2(bmap, blk);
/*
+ * Check to make sure the exclude bitmap for group is sane
+ */
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP)) {
+ blk = ext2fs_exclude_bitmap_loc(fs, i);
+ if (blk < first_block || blk > last_block ||
+ ext2fs_test_block_bitmap2(bmap, blk)) {
+ retval = EXT2_ET_GDESC_BAD_BLOCK_MAP;
+ goto errout;
+ }
+ ext2fs_mark_block_bitmap2(bmap, blk);
+ }
+
+ /*
* Check to make sure the inode bitmap for group is sane
*/
blk = ext2fs_inode_bitmap_loc(fs, i);
--
1.7.5.1
^ permalink raw reply related
* [PATCH 5/8] e2fsprogs: add exclude bitmap support in dumpe2fs
From: Yongqiang Yang @ 2011-10-23 7:21 UTC (permalink / raw)
To: linux-ext4; +Cc: amir73il, Yongqiang Yang
In-Reply-To: <1319354488-6050-1-git-send-email-xiaoqiangnk@gmail.com>
Exclude bitmap feature is needed by ext4 snapshot. This patch adds
exclude bitmap support in dumpe2fs.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
misc/dumpe2fs.c | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index df241c2..6b39575 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -119,6 +119,8 @@ static void print_bg_opts(ext2_filsys fs, dgrp_t i)
print_bg_opt(bg_flags, EXT2_BG_INODE_UNINIT, "INODE_UNINIT",
&first);
+ print_bg_opt(bg_flags, EXT2_BG_EXCLUDE_UNINIT, "EXCLUDE_UNINIT",
+ &first);
print_bg_opt(bg_flags, EXT2_BG_BLOCK_UNINIT, "BLOCK_UNINIT",
&first);
print_bg_opt(bg_flags, EXT2_BG_INODE_ZEROED, "ITABLE_ZEROED",
@@ -148,12 +150,13 @@ static void list_desc (ext2_filsys fs)
unsigned long i;
blk64_t first_block, last_block;
blk64_t super_blk, old_desc_blk, new_desc_blk;
- char *block_bitmap=NULL, *inode_bitmap=NULL;
+ char *block_bitmap = NULL, *exclude_bitmap = NULL, *inode_bitmap = NULL;
const char *units = _("blocks");
int inode_blocks_per_group, old_desc_blocks, reserved_gdt;
int block_nbytes, inode_nbytes;
int has_super;
blk64_t blk_itr = EXT2FS_B2C(fs, fs->super->s_first_data_block);
+ blk64_t exclude_itr = blk_itr;
ext2_ino_t ino_itr = 1;
if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
@@ -165,6 +168,8 @@ static void list_desc (ext2_filsys fs)
if (fs->block_map)
block_bitmap = malloc(block_nbytes);
+ if (fs->exclude_map)
+ exclude_bitmap = malloc(block_nbytes);
if (fs->inode_map)
inode_bitmap = malloc(inode_nbytes);
@@ -222,6 +227,14 @@ static void list_desc (ext2_filsys fs)
print_number(ext2fs_block_bitmap_loc(fs, i));
print_bg_rel_offset(fs, ext2fs_block_bitmap_loc(fs, i), 0,
first_block, last_block);
+ if (fs->super->s_feature_compat &
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) {
+ fputs(_(", snapshot bitmap at "), stdout);
+ print_number(ext2fs_exclude_bitmap_loc(fs, i));
+ print_bg_rel_offset(fs,
+ ext2fs_exclude_bitmap_loc(fs, i),
+ 0, first_block, last_block);
+ }
fputs(_(", Inode bitmap at "), stdout);
print_number(ext2fs_inode_bitmap_loc(fs, i));
print_bg_rel_offset(fs, ext2fs_inode_bitmap_loc(fs, i), 0,
@@ -252,6 +265,17 @@ static void list_desc (ext2_filsys fs)
fputc('\n', stdout);
blk_itr += fs->super->s_clusters_per_group;
}
+ if (exclude_bitmap) {
+ fputs(_(" Non-snapshot blocks: "), stdout);
+ ext2fs_get_exclude_bitmap_range2(fs->exclude_map,
+ exclude_itr, block_nbytes << 3, exclude_bitmap);
+ print_free(i, block_bitmap,
+ fs->super->s_clusters_per_group,
+ fs->super->s_first_data_block,
+ EXT2FS_CLUSTER_RATIO(fs));
+ fputc('\n', stdout);
+ exclude_itr += fs->super->s_blocks_per_group;
+ }
if (inode_bitmap) {
fputs(_(" Free inodes: "), stdout);
ext2fs_get_inode_bitmap_range2(fs->inode_map,
@@ -264,6 +288,8 @@ static void list_desc (ext2_filsys fs)
}
if (block_bitmap)
free(block_bitmap);
+ if (exclude_bitmap)
+ free(exclude_bitmap);
if (inode_bitmap)
free(inode_bitmap);
}
--
1.7.5.1
^ permalink raw reply related
* [PATCH 6/8] e2fsprogs: add exclude bitmap support in tune2fs
From: Yongqiang Yang @ 2011-10-23 7:21 UTC (permalink / raw)
To: linux-ext4; +Cc: amir73il, Yongqiang Yang
In-Reply-To: <1319354488-6050-1-git-send-email-xiaoqiangnk@gmail.com>
Exclude bitmap is a feature needed by ext4 snapshot. This patch
adds exclude bitmap support in tune2fs.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
misc/tune2fs.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 136 insertions(+), 3 deletions(-)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index e2fdb4a..02edcd6 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -129,7 +129,9 @@ static void usage(void)
static __u32 ok_features[3] = {
/* Compat */
EXT3_FEATURE_COMPAT_HAS_JOURNAL |
- EXT2_FEATURE_COMPAT_DIR_INDEX,
+ EXT2_FEATURE_COMPAT_DIR_INDEX |
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP,
+
/* Incompat */
EXT2_FEATURE_INCOMPAT_FILETYPE |
EXT3_FEATURE_INCOMPAT_EXTENTS |
@@ -149,7 +151,8 @@ static __u32 clear_ok_features[3] = {
/* Compat */
EXT3_FEATURE_COMPAT_HAS_JOURNAL |
EXT2_FEATURE_COMPAT_RESIZE_INODE |
- EXT2_FEATURE_COMPAT_DIR_INDEX,
+ EXT2_FEATURE_COMPAT_DIR_INDEX |
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP,
/* Incompat */
EXT2_FEATURE_INCOMPAT_FILETYPE |
EXT4_FEATURE_INCOMPAT_FLEX_BG |
@@ -288,6 +291,81 @@ static int release_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
}
/*
+ * Add exclude bitmaps to the filesystem
+ */
+static void add_exclude_bitmaps(ext2_filsys fs)
+{
+ char *buf = 0;
+ int retval, i;
+
+ retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf);
+ if (retval) {
+ fputs(_("Allocating memory failed.\n"), stderr);
+ exit(1);
+ }
+ strcpy(buf, "exclude bitmap for ");
+ strcat(buf, fs->device_name);
+
+ retval = ext2fs_allocate_exclude_bitmap(fs, buf,
+ &fs->exclude_map);
+ ext2fs_free_mem(&buf);
+ if (retval) {
+ fputs(_("Allocating exclude bitmap failed.\n"), stderr);
+ exit(1);
+ }
+
+ retval = ext2fs_read_block_bitmap(fs);
+ if (retval) {
+ ext2fs_free_exclude_bitmap(fs->exclude_map);
+ fputs(_("Reading block bitmap failed.\n"), stderr);
+ exit(1);
+ }
+
+ retval = ext2fs_allocate_tables(fs);
+ if (retval) {
+ ext2fs_free_exclude_bitmap(fs->exclude_map);
+ fputs(_("Allocating filesystem exclude bitmaps "
+ "failed.\n"), stderr);
+ exit(1);
+ }
+ fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
+ ext2fs_mark_bb_dirty(fs);
+ ext2fs_mark_eb_dirty(fs);
+ ext2fs_mark_super_dirty(fs);
+}
+
+/*
+ * Remove the exclude bitmaps from the filesystem
+ */
+static void remove_exclude_bitmaps(ext2_filsys fs)
+{
+ struct ext2_group_desc *gd;
+ int retval, i;
+
+ retval = ext2fs_read_block_bitmap(fs);
+ if (retval) {
+ fputs(_("Reading block bitmap failed.\n"), stderr);
+ exit(1);
+ }
+
+ for (i = 0; i < fs->group_desc_count; i++) {
+ blk64_t exclude_bitmap;
+ gd = ext2fs_group_desc(fs, fs->group_desc, i);
+ exclude_bitmap = ext2fs_exclude_bitmap_loc(fs, i);
+ release_blocks_proc(fs, &exclude_bitmap, 0, 0, 0, NULL);
+ ext2fs_exclude_bitmap_loc_set(fs, i, 0);
+ ext2fs_bg_flags_clear(fs, i, EXT2_BG_EXCLUDE_UNINIT);
+ if(EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_RO_COMPAT_GDT_CSUM))
+ ext2fs_group_desc_csum_set(fs, i);
+ }
+
+ fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
+ ext2fs_mark_bb_dirty(fs);
+ ext2fs_mark_super_dirty(fs);
+}
+
+/*
* Remove the journal inode from the filesystem
*/
static errcode_t remove_journal_inode(ext2_filsys fs)
@@ -363,6 +441,32 @@ static void request_fsck_afterwards(ext2_filsys fs)
printf(_("(and reboot afterwards!)\n"));
}
+static int verify_clean_fs(ext2_filsys fs, int compat, unsigned int mask,
+ int on)
+{
+ struct ext2_super_block *sb= fs->super;
+
+ if ((mount_flags & EXT2_MF_MOUNTED) &&
+ !(mount_flags & EXT2_MF_READONLY)) {
+ fprintf(stderr, _("The '%s' feature may only be "
+ "%s when the filesystem is\n"
+ "unmounted or mounted read-only.\n"),
+ e2p_feature2string(compat, mask),
+ on ? "set" : "cleared");
+ exit(1);
+ }
+ if (sb->s_feature_incompat &
+ EXT3_FEATURE_INCOMPAT_RECOVER) {
+ fprintf(stderr, _("The needs_recovery flag is set. "
+ "Please run e2fsck before %s\n"
+ "the '%s' flag.\n"),
+ on ? "setting" : "clearing",
+ e2p_feature2string(compat, mask));
+ exit(1);
+ }
+ return 1;
+}
+
/*
* Update the feature set as provided by the user.
*/
@@ -380,6 +484,10 @@ static int update_feature_set(ext2_filsys fs, char *features)
!((&sb->s_feature_compat)[(type)] & (mask)))
#define FEATURE_CHANGED(type, mask) ((mask) & \
(old_features[(type)] ^ (&sb->s_feature_compat)[(type)]))
+#define FEATURE_ON_SAFE(compat, mask) \
+ (FEATURE_ON(compat, mask) && verify_clean_fs(fs, compat, mask, 1))
+#define FEATURE_OFF_SAFE(compat, mask) \
+ (FEATURE_OFF(compat, mask) && verify_clean_fs(fs, compat, mask, 0))
old_features[E2P_FEATURE_COMPAT] = sb->s_feature_compat;
old_features[E2P_FEATURE_INCOMPAT] = sb->s_feature_incompat;
@@ -507,6 +615,16 @@ mmp_error:
sb->s_feature_compat &= ~EXT3_FEATURE_COMPAT_HAS_JOURNAL;
}
+ if (FEATURE_OFF_SAFE(E2P_FEATURE_COMPAT,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP)) {
+ remove_exclude_bitmaps(fs);
+ }
+
+ if (FEATURE_ON_SAFE(E2P_FEATURE_COMPAT,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP)) {
+ add_exclude_bitmaps(fs);
+ }
+
if (FEATURE_ON(E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX)) {
if (!sb->s_def_hash_version)
sb->s_def_hash_version = EXT2_HASH_HALF_MD4;
@@ -551,7 +669,7 @@ mmp_error:
for (i = 0; i < fs->group_desc_count; i++) {
gd = ext2fs_group_desc(fs, fs->group_desc, i);
if ((gd->bg_flags & EXT2_BG_INODE_ZEROED) == 0) {
- /*
+ /*
* XXX what we really should do is zap
* uninitialized inode tables instead.
*/
@@ -1318,6 +1436,10 @@ static int ext2fs_is_meta_block(ext2_filsys fs, blk_t blk)
group = ext2fs_group_of_blk(fs, blk);
if (ext2fs_block_bitmap_loc(fs, group) == blk)
return 1;
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ ext2fs_exclude_bitmap_loc(fs, group) == blk)
+ return 1;
if (ext2fs_inode_bitmap_loc(fs, group) == blk)
return 1;
return 0;
@@ -1536,6 +1658,17 @@ static int group_desc_scan_and_fix(ext2_filsys fs, ext2fs_block_bitmap bmap)
ext2fs_block_bitmap_loc_set(fs, i, new_blk);
}
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP)) {
+ blk = ext2fs_exclude_bitmap_loc(fs, i);
+ if (ext2fs_test_block_bitmap(bmap, blk)) {
+ new_blk = translate_block(blk);
+ if (!new_blk)
+ continue;
+ ext2fs_exclude_bitmap_loc_set(fs, i, new_blk);
+ }
+ }
+
blk = ext2fs_inode_bitmap_loc(fs, i);
if (ext2fs_test_block_bitmap2(bmap, blk)) {
new_blk = translate_block(blk);
--
1.7.5.1
^ permalink raw reply related
* yuming wu shared photos with you
From: yuming wu @ 2011-10-23 9:11 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 412 bytes --]
Hello,sir
Thank you for your time
Here is our stage lighting, disco and dj lighting equipment price list, if
you are interest, please contact us soonest.
Thank you
Mr.wu
WWW(DOT)DJ-EUROPE(DOT)COM
NO.FLAT 4-5, EDUCATION ROAD EAST, CHENXI CUN, NANHAI DISTRICT, FOSHAN CITY,
CHINA
POSTCODE: 528248 TELEPHONE: 0086-757-63386561
FAX: 0086-757-63386562 EMAIL: FACTORY1@DJ-EUROPE.COM FACTORY2@DJ-EUROPE.COM
[-- Attachment #2: 87.jpg --]
[-- Type: image/jpeg, Size: 19684 bytes --]
^ permalink raw reply
* [PATCH 7/8] e2fsprogs: add exclude bitmap support in e2image
From: Yongqiang Yang @ 2011-10-23 7:21 UTC (permalink / raw)
To: linux-ext4; +Cc: amir73il, Yongqiang Yang
In-Reply-To: <1319354488-6050-1-git-send-email-xiaoqiangnk@gmail.com>
Exclude bitmap is a feature needed by ext4 snapshot. This patch
Adds exclude bitmap support in e2image.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
lib/ext2fs/e2image.h | 1 +
lib/ext2fs/ext2fs.h | 1 +
lib/ext2fs/imager.c | 22 ++++++++++++++++++++++
lib/ext2fs/rw_bitmaps.c | 16 ++++++++++++++++
misc/e2image.c | 22 ++++++++++++++++++++++
5 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/lib/ext2fs/e2image.h b/lib/ext2fs/e2image.h
index c918529..61d7ff9 100644
--- a/lib/ext2fs/e2image.h
+++ b/lib/ext2fs/e2image.h
@@ -41,6 +41,7 @@ struct ext2_image_hdr {
__u32 offset_super; /* Byte offset of the sb and descriptors */
__u32 offset_inode; /* Byte offset of the inode table */
__u32 offset_inodemap; /* Byte offset of the inode bitmaps */
+ __u32 offset_excludemap; /* Byte offset of the exclude bitmaps */
__u32 offset_blockmap; /* Byte offset of the inode bitmaps */
__u32 offset_reserved[8];
};
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index d1f0d98..dab5ad7 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -526,6 +526,7 @@ typedef struct ext2_icount *ext2_icount_t;
*/
#define IMAGER_FLAG_INODEMAP 1
#define IMAGER_FLAG_SPARSEWRITE 2
+#define IMAGER_FLAG_EXCLUDEMAP 3
/*
* For checking structure magic numbers...
diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c
index a0fb81e..c6b5af2 100644
--- a/lib/ext2fs/imager.c
+++ b/lib/ext2fs/imager.c
@@ -296,6 +296,17 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)
itr = 1;
cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
size = (EXT2_INODES_PER_GROUP(fs->super) / 8);
+ } else if (flags & IMAGER_FLAG_EXCLUDEMAP) {
+ if (!fs->exclude_map) {
+ retval = ext2fs_read_exclude_bitmap(fs);
+ if (retval)
+ return retval;
+ }
+ bmap = fs->exclude_map;
+ err = EXT2_ET_MAGIC_EXCLUDE_BITMAP;
+ itr = fs->super->s_first_data_block;
+ cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count;
+ size = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
} else {
if (!fs->block_map) {
retval = ext2fs_read_block_bitmap(fs);
@@ -373,6 +384,17 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
itr = 1;
cnt = EXT2_INODES_PER_GROUP(fs->super) * fs->group_desc_count;
size = (EXT2_INODES_PER_GROUP(fs->super) / 8);
+ } else if (flags & IMAGER_FLAG_EXCLUDEMAP) {
+ if (!fs->exclude_map) {
+ retval = ext2fs_read_exclude_bitmap(fs);
+ if (retval)
+ return retval;
+ }
+ bmap = fs->exclude_map;
+ err = EXT2_ET_MAGIC_EXCLUDE_BITMAP;
+ itr = fs->super->s_first_data_block;
+ cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count;
+ size = EXT2_BLOCKS_PER_GROUP(fs->super) / 8;
} else {
if (!fs->block_map) {
retval = ext2fs_read_block_bitmap(fs);
diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c
index 3126733..6c8179b 100644
--- a/lib/ext2fs/rw_bitmaps.c
+++ b/lib/ext2fs/rw_bitmaps.c
@@ -274,6 +274,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block,
ext2fs_free_mem(&buf);
if (fs->flags & EXT2_FLAG_IMAGE_FILE) {
+ blk64_t exclude_blk;
blk = (fs->image_header->offset_inodemap / fs->blocksize);
ino_cnt = fs->super->s_inodes_count;
while (inode_nbytes > 0) {
@@ -294,10 +295,25 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block,
}
blk = (fs->image_header->offset_blockmap /
fs->blocksize);
+ exclude_blk = (fs->image_header->offset_excludemap /
+ fs->blocksize);
blk_cnt = (blk64_t)EXT2_CLUSTERS_PER_GROUP(fs->super) *
fs->group_desc_count;
while (block_nbytes > 0) {
if (do_exclude) {
+ retval = io_channel_read_blk64(fs->image_io,
+ exclude_blk++, 1, exclude_bitmap);
+ if (retval)
+ goto cleanup;
+ cnt = fs->blocksize << 3;
+ if (cnt > blk_cnt)
+ cnt = blk_cnt;
+ retval = ext2fs_set_exclude_bitmap_range2(
+ fs->exclude_map,
+ blk_itr, cnt, exclude_bitmap);
+ if (retval)
+ goto cleanup;
+
retval = EXT2_ET_EXCLUDE_BITMAP_READ;
goto cleanup;
}
diff --git a/misc/e2image.c b/misc/e2image.c
index 4cd834a..44a602c 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -187,6 +187,18 @@ static void write_image_file(ext2_filsys fs, int fd)
exit(1);
}
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP)) {
+ hdr.offset_excludemap = lseek(fd, 0, SEEK_CUR);
+ retval = ext2fs_image_bitmap_write(fs, fd,
+ IMAGER_FLAG_EXCLUDEMAP);
+ if (retval) {
+ com_err(program_name, retval, _("while writing "
+ "exclude bitmap"));
+ exit(1);
+ }
+ }
+
hdr.offset_inodemap = ext2fs_llseek(fd, 0, SEEK_CUR);
retval = ext2fs_image_bitmap_write(fs, fd, IMAGER_FLAG_INODEMAP);
if (retval) {
@@ -359,6 +371,16 @@ static void mark_table_blocks(ext2_filsys fs)
}
/*
+ * Mark block used for the exclude bitmap
+ */
+ if (EXT2_HAS_COMPAT_FEATURE(fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP) &&
+ ext2fs_exclude_bitmap_loc(fs, i)) {
+ ext2fs_mark_block_bitmap2(meta_block_map,
+ ext2fs_exclude_bitmap_loc(fs, i));
+ }
+
+ /*
* Mark block used for the inode bitmap
*/
if (ext2fs_inode_bitmap_loc(fs, i)) {
--
1.7.5.1
^ permalink raw reply related
* [PATCH 8/8] e2fsprogs: add exclude bitmap support in debugfs
From: Yongqiang Yang @ 2011-10-23 7:21 UTC (permalink / raw)
To: linux-ext4; +Cc: amir73il, Yongqiang Yang
In-Reply-To: <1319354488-6050-1-git-send-email-xiaoqiangnk@gmail.com>
Exclude bitmap is a feature needed by ext4 snapshot. This patch
adds exclude bitmap support in debugfs.
Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
debugfs/debug_cmds.ct | 9 +++++
debugfs/debugfs.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++--
debugfs/set_fields.c | 1 +
lib/ext2fs/bitops.h | 49 +++++++++++++++++++++++++++++
4 files changed, 136 insertions(+), 4 deletions(-)
diff --git a/debugfs/debug_cmds.ct b/debugfs/debug_cmds.ct
index ea677da..2098f29 100644
--- a/debugfs/debug_cmds.ct
+++ b/debugfs/debug_cmds.ct
@@ -88,6 +88,15 @@ request do_setb, "Set a block's in-use flag",
request do_testb, "Test a block's in-use flag",
testb;
+request do_freee, "Clear a block's exclude flag",
+ freee;
+
+request do_sete, "Set a block's exclude flag",
+ sete;
+
+request do_teste, "Test a block's exclude flag",
+ teste;
+
request do_modify_inode, "Modify an inode by structure",
modify_inode, mi;
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index dd1435b..f839563 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -98,6 +98,11 @@ static void open_filesystem(char *device, int open_flags, blk64_t superblock,
com_err(device, retval, "while reading inode bitmap");
goto errout;
}
+ retval = ext2fs_read_exclude_bitmap(current_fs);
+ if (retval) {
+ com_err(device, retval, "while reading exclude bitmap");
+ goto errout;
+ }
retval = ext2fs_read_block_bitmap(current_fs);
if (retval) {
com_err(device, retval, "while reading block bitmap");
@@ -352,12 +357,14 @@ void do_show_super_stats(int argc, char *argv[])
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
for (i = 0; i < current_fs->group_desc_count; i++) {
fprintf(out, " Group %2d: block bitmap at %llu, "
+ "exlcude bitmap at %llu, "
"inode bitmap at %llu, "
"inode table at %llu\n"
" %u free %s%s, "
"%u free %s, "
"%u used %s%s",
i, ext2fs_block_bitmap_loc(current_fs, i),
+ ext2fs_exclude_bitmap_loc(current_fs, i),
ext2fs_inode_bitmap_loc(current_fs, i),
ext2fs_inode_table_loc(current_fs, i),
ext2fs_bg_free_blocks_count(current_fs, i), units,
@@ -375,10 +382,12 @@ void do_show_super_stats(int argc, char *argv[])
ext2fs_bg_itable_unused(current_fs, i) != 1 ?
"inodes" : "inode");
first = 1;
- print_bg_opts(current_fs, i, EXT2_BG_INODE_UNINIT, "Inode not init",
- &first, out);
- print_bg_opts(current_fs, i, EXT2_BG_BLOCK_UNINIT, "Block not init",
- &first, out);
+ print_bg_opts(current_fs, i, EXT2_BG_INODE_UNINIT,
+ "Inode not init", &first, out);
+ print_bg_opts(current_fs, i, EXT2_BG_EXCLUDE_UNINIT,
+ "Exclude not init", &first, out);
+ print_bg_opts(current_fs, i, EXT2_BG_BLOCK_UNINIT,
+ "Block not init", &first, out);
if (gdt_csum) {
fprintf(out, "%sChecksum 0x%04x",
first ? " [":", ", ext2fs_bg_checksum(current_fs, i));
@@ -1074,6 +1083,70 @@ void do_testb(int argc, char *argv[])
}
}
+void do_freee(int argc, char *argv[])
+{
+ blk64_t block;
+ blk64_t count = 1;
+
+ if (!EXT2_HAS_COMPAT_FEATURE(current_fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP))
+ return;
+ if (common_block_args_process(argc, argv, &block, &count))
+ return;
+ if (check_fs_read_write(argv[0]))
+ return;
+ while (count-- > 0) {
+ if (!ext2fs_test_exclude_bitmap2(current_fs->exclude_map,
+ block))
+ com_err(argv[0], 0, "Warning: block %llu already "
+ "not excluded", block);
+ ext2fs_unmark_exclude_bitmap2(current_fs->exclude_map, block);
+ block++;
+ }
+ ext2fs_mark_eb_dirty(current_fs);
+}
+
+void do_sete(int argc, char *argv[])
+{
+ blk64_t block;
+ blk64_t count = 1;
+
+ if (!EXT2_HAS_COMPAT_FEATURE(current_fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP))
+ return;
+ if (common_block_args_process(argc, argv, &block, &count))
+ return;
+ if (check_fs_read_write(argv[0]))
+ return;
+ while (count-- > 0) {
+ if (ext2fs_test_exclude_bitmap2(current_fs->exclude_map, block))
+ com_err(argv[0], 0, "Warning: block %llu already "
+ "excluded", block);
+ ext2fs_mark_exclude_bitmap2(current_fs->exclude_map, block);
+ block++;
+ }
+ ext2fs_mark_eb_dirty(current_fs);
+}
+
+void do_teste(int argc, char *argv[])
+{
+ blk64_t block;
+ blk64_t count = 1;
+
+ if (!EXT2_HAS_COMPAT_FEATURE(current_fs->super,
+ EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP))
+ return;
+ if (common_block_args_process(argc, argv, &block, &count))
+ return;
+ while (count-- > 0) {
+ if (ext2fs_test_exclude_bitmap2(current_fs->exclude_map, block))
+ printf("Block %llu marked excluded\n", block);
+ else
+ printf("Block %llu not excluded\n", block);
+ block++;
+ }
+}
+
static void modify_u8(char *com, const char *prompt,
const char *format, __u8 *val)
{
diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c
index d461275..7ecf7d8 100644
--- a/debugfs/set_fields.c
+++ b/debugfs/set_fields.c
@@ -205,6 +205,7 @@ static struct field_set_info inode_fields[] = {
static struct field_set_info ext2_bg_fields[] = {
{ "block_bitmap", &set_gd.bg_block_bitmap, NULL, 4, parse_uint },
+ { "exclude_bitmap", &set_gd.bg_exclude_bitmap_lo, NULL, 4, parse_uint },
{ "inode_bitmap", &set_gd.bg_inode_bitmap, NULL, 4, parse_uint },
{ "inode_table", &set_gd.bg_inode_table, NULL, 4, parse_uint },
{ "free_blocks_count", &set_gd.bg_free_blocks_count, NULL, 2, parse_uint },
diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h
index 83a01e4..64d14f9 100644
--- a/lib/ext2fs/bitops.h
+++ b/lib/ext2fs/bitops.h
@@ -72,6 +72,13 @@ extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
blk_t block);
extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
+extern int ext2fs_mark_exclude_bitmap(ext2fs_exclude_bitmap bitmap,
+ blk_t block);
+extern int ext2fs_unmark_exclude_bitmap(ext2fs_exclude_bitmap bitmap,
+ blk_t block);
+extern int ext2fs_test_exclude_bitmap(ext2fs_exclude_bitmap bitmap,
+ blk_t block);
+
extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode);
@@ -415,6 +422,27 @@ _INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap,
block);
}
+_INLINE_ int ext2fs_mark_exclude_bitmap(ext2fs_exclude_bitmap bitmap,
+ blk_t block)
+{
+ return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
+ block);
+}
+
+_INLINE_ int ext2fs_unmark_exclude_bitmap(ext2fs_exclude_bitmap bitmap,
+ blk_t block)
+{
+ return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
+ block);
+}
+
+_INLINE_ int ext2fs_test_exclude_bitmap(ext2fs_exclude_bitmap bitmap,
+ blk_t block)
+{
+ return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
+ block);
+}
+
_INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
@@ -534,6 +562,27 @@ _INLINE_ int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
block);
}
+_INLINE_ int ext2fs_mark_exclude_bitmap2(ext2fs_exclude_bitmap bitmap,
+ blk64_t block)
+{
+ return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
+ block);
+}
+
+_INLINE_ int ext2fs_unmark_exclude_bitmap2(ext2fs_exclude_bitmap bitmap,
+ blk64_t block)
+{
+ return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
+ block);
+}
+
+_INLINE_ int ext2fs_test_exclude_bitmap2(ext2fs_exclude_bitmap bitmap,
+ blk64_t block)
+{
+ return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
+ block);
+}
+
_INLINE_ int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
ext2_ino_t inode)
{
--
1.7.5.1
^ permalink raw reply related
* [RFC][PATCH] uncompress.h cleanup and DT support
From: Zoltan Devai @ 2011-10-23 9:12 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <20111023084132.GA12814@n2100.arm.linux.org.uk>
2011/10/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> On Sun, Oct 23, 2011 at 10:18:29AM +0200, Zoltan Devai wrote:
>> Plase consider all this as RFC, it's mostly not even compile-tested.
>> If you think it's worth to follow-up, I'm happy to do it.
>
> Is the patch available?
git://github.com/zdevai/linux.git uncompress-h
> Has this been tested with ZBOOT_ROM?
Not yet, but I don't see a reason why this would break it.
Zoltan
^ permalink raw reply
* question about relationship between /var/lib/xenstored/tdb and xenstore_domain_interface
From: zhao bao @ 2011-10-23 9:13 UTC (permalink / raw)
To: xen-devel
Hi, when I read following link,
http://wiki.xen.org/xenwiki/XenIntro
, then I browsed some Xen 3.1 code. A question puzzles me.
As we know "The physical xenstore resides in one file:
/var/lib/xenstored/tdb. " , but drives(frontend/backend) visit
Xenstore by Xenbus. The data structure manipulated by Xenbus is
xenstore_domain_interface, not tdb. while tdb file is visited by
Xenstored daemon.
I cann't figure out the relationship between tdb and xenstore_domain_interface.
For example, if Xenbus sends a XS_DIRECTORY query message , where
does the reply message come from?
Thanks in advance!
^ permalink raw reply
* [RFC][PATCH] uncompress.h cleanup and DT support
From: Russell King - ARM Linux @ 2011-10-23 9:20 UTC (permalink / raw)
To: linux-arm-kernel
In-Reply-To: <CAGVye5NQa857oNPEgQBWE0twQHL6U3BTeSOaR2aTiJzUxMvFSg@mail.gmail.com>
On Sun, Oct 23, 2011 at 11:12:50AM +0200, Zoltan Devai wrote:
> 2011/10/23 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> > On Sun, Oct 23, 2011 at 10:18:29AM +0200, Zoltan Devai wrote:
> >> Plase consider all this as RFC, it's mostly not even compile-tested.
> >> If you think it's worth to follow-up, I'm happy to do it.
> >
> > Is the patch available?
> git://github.com/zdevai/linux.git uncompress-h
I'd rather not pull your tree just to look at the patch. Is it
available somewhere else?
> > Has this been tested with ZBOOT_ROM?
> Not yet, but I don't see a reason why this would break it.
Please try building it with ZBOOT_ROM enabled.
^ permalink raw reply
* Bisected: Massive memory leak in dm-snapshot in 3.1 development introduced
From: Michael Leun @ 2011-10-23 9:21 UTC (permalink / raw)
To: LKML, dm-devel, Linus Torvalds, Mikulas Patocka
Hi,
How to reproduce:
lvcreate -L30G -n testsnap vg1 # of course substitute VG as appropriate
dd if=/dev/zero of=/dev/vg1/testsnap bs=2M # to make things clear
lvcreate -L15G -s /dev/vg1/test -n testsnap
dd if=/dev/zero of=/dev/vg1/testsnap bs=2M &
watch free
I noticed roughly 1GB memory vanishing from free / -/+ buffers/cache
per 2GB copied.
Bisecting yielded a6e50b409d3f9e0833e69c3c9cca822e8fa4adbb, reverting
that from git master cures the memory leak
--
MfG,
Michael Leun
^ permalink raw reply
* Re: copy_*_user
From: Xin Tong @ 2011-10-23 9:23 UTC (permalink / raw)
To: Américo Wang; +Cc: linux-kernel
In-Reply-To: <CAM_iQpU+xHww_JCYYA4kAKCXmOZpZeu=+rnCyRL-5dW5Uxk1hQ@mail.gmail.com>
I found that __copy_from_user_ll(void *to, const void __user *from,
unsigned long n) eventually calls some asm which use mov and rep on
the passed-in to & from pointers. This is in kernel mode and to & from
are virtual addresses ? are not the kernel accessing physical RAM
directly ( without pagetable ) ?
Thanks
Xin
On Sat, Oct 22, 2011 at 10:50 PM, Américo Wang <xiyou.wangcong@gmail.com> wrote:
> On Sun, Oct 23, 2011 at 1:06 AM, Xin Tong <xerox.time.tech@gmail.com> wrote:
>> I am investigating copy_from_user and copy_to_user in linux under
>> i386. These two function both take a pointer with virtual address and
>> a pointer with physical address.
>>
>> copy_from_user calls __copy_from_user_ll and copy_to_user calls
>> __copy_to_user_ll. It make sense to me that __copy_to_user_ll converts
>> the virtual address to physical address using the current process's
>> page table.
>>
> [...]
>> But it seems to be that __copy_from_user_ll is not converted the
>> address at all before attempting to copy. Can someone help explain to
>> me why ?
>>
>
> You missed that __copy_to_user_ll() only does that when CONFIG_X86_WP_WORKS_OK
> is not defined. And there is a comment right inside __copy_to_user_ll() said:
>
>
> /*
> * CPU does not honor the WP bit when writing
> * from supervisory mode, and due to preemption or SMP,
> * the page tables can change at any time.
> * Do it manually. Manfred <manfred@colorfullife.com>
> */
>
> this is why it uses kmap_atomic()+memcpy() to copy the data.
>
> Also, all the addresses are virtual address.
>
^ permalink raw reply
* [PATCH 00/12 RESEND] Mainly checkpatch fixes
From: Mark Einon @ 2011-10-23 9:22 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-kernel
Resending patches. Reduces the number of checkpatch warnings, removing forward declarations and whitespace changes.
Last patch removes some redundant code.
Mark Einon (12):
staging: et131x: Remove unused rx_ring.recv_buffer_pool
staging: et131x: Remove redundant et131x_reset_recv() call
staging: et131x: Remove call to find pci pm capability
staging: et131x: Remove unused rx_ring.recv_packet_pool
staging: et131x: Remove some forward declarations
staging: et131x: Remove forward declaration of et131x_adapter_setup
staging: et131x: Remove more forward declarations
staging: et131x: Remove yet more forward declarations
staging: et131x: Remove even more forward declarations
staging: et131x: Remove last of the forward declarations
staging: et131x: Mainly whitespace changes to appease checkpatch
staging: et131x: Remove redundant check and return statement
drivers/staging/et131x/et131x.c | 2465 +++++++++++++++++++--------------------
1 files changed, 1201 insertions(+), 1264 deletions(-)
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.