* [PATCH 2/2] E2fsprogs: add compress and cow support in chattr, lsattr
[not found] ` <4DA692C8.2080400@cn.fujitsu.com>
@ 2011-04-18 7:37 ` liubo
2015-01-02 10:22 ` Lutz Vieweg
0 siblings, 1 reply; 4+ messages in thread
From: liubo @ 2011-04-18 7:37 UTC (permalink / raw)
To: ext4; +Cc: Linux Btrfs, tytso, Chris Mason
Modify command 'chattr' and 'lsattr' to support compress and cow.
- use 'C' to indicate NOCOW attribute.
- still use 'c' to indicate compress attribute.
Also update the man doc.
Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
---
lib/e2p/pf.c | 1 +
lib/ext2fs/ext2_fs.h | 1 +
misc/chattr.1.in | 15 +++++++++++----
misc/chattr.c | 15 ++++++++++++++-
4 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/lib/e2p/pf.c b/lib/e2p/pf.c
index cc50896..c9385dd 100644
--- a/lib/e2p/pf.c
+++ b/lib/e2p/pf.c
@@ -48,6 +48,7 @@ static struct flags_name flags_array[] = {
{ FS_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
{ EXT4_EXTENTS_FL, "e", "Extents" },
{ EXT4_HUGE_FILE_FL, "h", "Huge_file" },
+ { FS_NOCOW_FL, "C", "NOCOW" },
{ 0, NULL, NULL }
};
diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
index 858c103..776be92 100644
--- a/lib/ext2fs/ext2_fs.h
+++ b/lib/ext2fs/ext2_fs.h
@@ -276,6 +276,7 @@ struct ext2_dx_countlimit {
#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
#define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
#define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
+#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
#define EXT4_SNAPFILE_FL 0x01000000 /* Inode is a snapshot */
#define EXT4_SNAPFILE_DELETED_FL 0x04000000 /* Snapshot is being deleted */
#define EXT4_SNAPFILE_SHRUNK_FL 0x08000000 /* Snapshot shrink has completed */
diff --git a/misc/chattr.1.in b/misc/chattr.1.in
index 92f6d70..434eb04 100644
--- a/misc/chattr.1.in
+++ b/misc/chattr.1.in
@@ -19,17 +19,18 @@ chattr \- change file attributes on a Linux file system
.B chattr
changes the file attributes on a Linux file system.
.PP
-The format of a symbolic mode is +-=[acdeijstuADST].
+The format of a symbolic mode is +-=[acdeijstuACDST].
.PP
The operator `+' causes the selected attributes to be added to the
existing attributes of the files; `-' causes them to be removed; and
`=' causes them to be the only attributes that the files have.
.PP
-The letters `acdeijstuADST' select the new attributes for the files:
+The letters `acdeijstuACDST' select the new attributes for the files:
append only (a), compressed (c), no dump (d), extent format (e), immutable (i),
data journalling (j), secure deletion (s), no tail-merging (t),
-undeletable (u), no atime updates (A), synchronous directory updates (D),
-synchronous updates (S), and top of directory hierarchy (T).
+undeletable (u), no atime updates (A), no copy on write (C),
+synchronous directory updates (D), synchronous updates (S),
+and top of directory hierarchy (T).
.PP
The following attributes are read-only, and may be listed by
.BR lsattr (1)
@@ -64,6 +65,10 @@ this file compresses data before storing them on the disk. Note: please
make sure to read the bugs and limitations section at the end of this
document.
.PP
+A file with the `C' attribute set is marked without COW (copy on write). Note:
+please make sure to read the bugs and limitations section at the end of this
+document.
+.PP
When a directory with the `D' attribute set is modified,
the changes are written synchronously on the disk; this is equivalent to
the `dirsync' mount option applied to a subset of the files.
@@ -161,6 +166,8 @@ The `c', 's', and `u' attributes are not honored
by the ext2 and ext3 filesystems as implemented in the current mainline
Linux kernels. These attributes may be implemented
in future versions of the ext2 and ext3 filesystems.
+The `C' attribute is only used in btrfs filesystem in the current mainline
+Linux kernels.
.PP
The `j' option is only useful if the filesystem is mounted as ext3.
.PP
diff --git a/misc/chattr.c b/misc/chattr.c
index 78e3736..8c8231e 100644
--- a/misc/chattr.c
+++ b/misc/chattr.c
@@ -82,7 +82,7 @@ static unsigned long sf;
static void usage(void)
{
fprintf(stderr,
- _("Usage: %s [-RVf] [-+=AacDdeijsSu] [-v version] files...\n"),
+ _("Usage: %s [-RVf] [-+=AacDdeijsSuC] [-v version] files...\n"),
program_name);
exit(1);
}
@@ -106,6 +106,7 @@ static const struct flags_char flags_array[] = {
{ FS_UNRM_FL, 'u' },
{ FS_NOTAIL_FL, 't' },
{ FS_TOPDIR_FL, 'T' },
+ { FS_NOCOW_FL, 'C' },
{ 0, 0 }
};
@@ -159,6 +160,12 @@ static int decode_arg (int * i, int argc, char ** argv)
}
if ((fl = get_flag(*p)) == 0)
usage();
+
+ if (fl == FS_COMPR_FL) {
+ af |= FS_NOCOMPR_FL;
+ add = 1;
+ }
+
rf |= fl;
rem = 1;
}
@@ -168,6 +175,12 @@ static int decode_arg (int * i, int argc, char ** argv)
for (p = &argv[*i][1]; *p; p++) {
if ((fl = get_flag(*p)) == 0)
usage();
+
+ if (fl == FS_COMPR_FL) {
+ rf |= FS_NOCOMPR_FL;
+ rem = 1;
+ }
+
af |= fl;
}
break;
--
1.6.5.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] E2fsprogs: add compress and cow support in chattr, lsattr
2011-04-18 7:37 ` [PATCH 2/2] E2fsprogs: add compress and cow support in chattr, lsattr liubo
@ 2015-01-02 10:22 ` Lutz Vieweg
2015-01-04 10:40 ` Erkki Seppala
0 siblings, 1 reply; 4+ messages in thread
From: Lutz Vieweg @ 2015-01-02 10:22 UTC (permalink / raw)
To: linux-btrfs
On 04/18/2011 09:37 AM, liubo wrote:
> Modify command 'chattr' and 'lsattr' to support compress and cow.
> - use 'C' to indicate NOCOW attribute.
It's kind of confusing for new users that when one sets
> chattr +C someexistingfile
on btrfs, a subsequent
> lsattr someexistingfile
will show the C flag as "not set". It takes some
reading to realize that btrfs cannot change the non-COW
flag on files bigger than 0 bytes.
Maybe "chattr +C" could print a warning if a file
to change attributes for is > 0 bytes long?
Regards,
Lutz Vieweg
> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
> ---
> lib/e2p/pf.c | 1 +
> lib/ext2fs/ext2_fs.h | 1 +
> misc/chattr.1.in | 15 +++++++++++----
> misc/chattr.c | 15 ++++++++++++++-
> 4 files changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/lib/e2p/pf.c b/lib/e2p/pf.c
> index cc50896..c9385dd 100644
> --- a/lib/e2p/pf.c
> +++ b/lib/e2p/pf.c
> @@ -48,6 +48,7 @@ static struct flags_name flags_array[] = {
> { FS_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" },
> { EXT4_EXTENTS_FL, "e", "Extents" },
> { EXT4_HUGE_FILE_FL, "h", "Huge_file" },
> + { FS_NOCOW_FL, "C", "NOCOW" },
> { 0, NULL, NULL }
> };
>
> diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
> index 858c103..776be92 100644
> --- a/lib/ext2fs/ext2_fs.h
> +++ b/lib/ext2fs/ext2_fs.h
> @@ -276,6 +276,7 @@ struct ext2_dx_countlimit {
> #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
> #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
> #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
> +#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
> #define EXT4_SNAPFILE_FL 0x01000000 /* Inode is a snapshot */
> #define EXT4_SNAPFILE_DELETED_FL 0x04000000 /* Snapshot is being deleted */
> #define EXT4_SNAPFILE_SHRUNK_FL 0x08000000 /* Snapshot shrink has completed */
> diff --git a/misc/chattr.1.in b/misc/chattr.1.in
> index 92f6d70..434eb04 100644
> --- a/misc/chattr.1.in
> +++ b/misc/chattr.1.in
> @@ -19,17 +19,18 @@ chattr \- change file attributes on a Linux file system
> .B chattr
> changes the file attributes on a Linux file system.
> .PP
> -The format of a symbolic mode is +-=[acdeijstuADST].
> +The format of a symbolic mode is +-=[acdeijstuACDST].
> .PP
> The operator `+' causes the selected attributes to be added to the
> existing attributes of the files; `-' causes them to be removed; and
> `=' causes them to be the only attributes that the files have.
> .PP
> -The letters `acdeijstuADST' select the new attributes for the files:
> +The letters `acdeijstuACDST' select the new attributes for the files:
> append only (a), compressed (c), no dump (d), extent format (e), immutable (i),
> data journalling (j), secure deletion (s), no tail-merging (t),
> -undeletable (u), no atime updates (A), synchronous directory updates (D),
> -synchronous updates (S), and top of directory hierarchy (T).
> +undeletable (u), no atime updates (A), no copy on write (C),
> +synchronous directory updates (D), synchronous updates (S),
> +and top of directory hierarchy (T).
> .PP
> The following attributes are read-only, and may be listed by
> .BR lsattr (1)
> @@ -64,6 +65,10 @@ this file compresses data before storing them on the disk. Note: please
> make sure to read the bugs and limitations section at the end of this
> document.
> .PP
> +A file with the `C' attribute set is marked without COW (copy on write). Note:
> +please make sure to read the bugs and limitations section at the end of this
> +document.
> +.PP
> When a directory with the `D' attribute set is modified,
> the changes are written synchronously on the disk; this is equivalent to
> the `dirsync' mount option applied to a subset of the files.
> @@ -161,6 +166,8 @@ The `c', 's', and `u' attributes are not honored
> by the ext2 and ext3 filesystems as implemented in the current mainline
> Linux kernels. These attributes may be implemented
> in future versions of the ext2 and ext3 filesystems.
> +The `C' attribute is only used in btrfs filesystem in the current mainline
> +Linux kernels.
> .PP
> The `j' option is only useful if the filesystem is mounted as ext3.
> .PP
> diff --git a/misc/chattr.c b/misc/chattr.c
> index 78e3736..8c8231e 100644
> --- a/misc/chattr.c
> +++ b/misc/chattr.c
> @@ -82,7 +82,7 @@ static unsigned long sf;
> static void usage(void)
> {
> fprintf(stderr,
> - _("Usage: %s [-RVf] [-+=AacDdeijsSu] [-v version] files...\n"),
> + _("Usage: %s [-RVf] [-+=AacDdeijsSuC] [-v version] files...\n"),
> program_name);
> exit(1);
> }
> @@ -106,6 +106,7 @@ static const struct flags_char flags_array[] = {
> { FS_UNRM_FL, 'u' },
> { FS_NOTAIL_FL, 't' },
> { FS_TOPDIR_FL, 'T' },
> + { FS_NOCOW_FL, 'C' },
> { 0, 0 }
> };
>
> @@ -159,6 +160,12 @@ static int decode_arg (int * i, int argc, char ** argv)
> }
> if ((fl = get_flag(*p)) == 0)
> usage();
> +
> + if (fl == FS_COMPR_FL) {
> + af |= FS_NOCOMPR_FL;
> + add = 1;
> + }
> +
> rf |= fl;
> rem = 1;
> }
> @@ -168,6 +175,12 @@ static int decode_arg (int * i, int argc, char ** argv)
> for (p = &argv[*i][1]; *p; p++) {
> if ((fl = get_flag(*p)) == 0)
> usage();
> +
> + if (fl == FS_COMPR_FL) {
> + rf |= FS_NOCOMPR_FL;
> + rem = 1;
> + }
> +
> af |= fl;
> }
> break;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] E2fsprogs: add compress and cow support in chattr, lsattr
2015-01-02 10:22 ` Lutz Vieweg
@ 2015-01-04 10:40 ` Erkki Seppala
2015-01-04 19:41 ` Martin Steigerwald
0 siblings, 1 reply; 4+ messages in thread
From: Erkki Seppala @ 2015-01-04 10:40 UTC (permalink / raw)
To: linux-btrfs
Lutz Vieweg <lvml@5t9.de> writes:
> Maybe "chattr +C" could print a warning if a file
> to change attributes for is > 0 bytes long?
This may only affect btrfs. The old ext2? ext3? compression patches
were able to compress pre-existing files. I don't know how other
filesystems behave in this regard.
--
_____________________________________________________________________
/ __// /__ ____ __ http://www.modeemi.fi/~flux/\ \
/ /_ / // // /\ \/ / \ /
/_/ /_/ \___/ /_/\_\@modeemi.fi \/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] E2fsprogs: add compress and cow support in chattr, lsattr
2015-01-04 10:40 ` Erkki Seppala
@ 2015-01-04 19:41 ` Martin Steigerwald
0 siblings, 0 replies; 4+ messages in thread
From: Martin Steigerwald @ 2015-01-04 19:41 UTC (permalink / raw)
To: Erkki Seppala; +Cc: linux-btrfs
Am Sonntag, 4. Januar 2015, 12:40:59 schrieb Erkki Seppala:
> Lutz Vieweg <lvml@5t9.de> writes:
>
> > Maybe "chattr +C" could print a warning if a file
> > to change attributes for is > 0 bytes long?
>
> This may only affect btrfs. The old ext2? ext3? compression patches
> were able to compress pre-existing files. I don't know how other
> filesystems behave in this regard.
+C is no-cow, -c is compression.
--
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA B82F 991B EAAC A599 84C7
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-04 19:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <4DA2A15C.1050501@cn.fujitsu.com>
[not found] ` <4DA692C8.2080400@cn.fujitsu.com>
2011-04-18 7:37 ` [PATCH 2/2] E2fsprogs: add compress and cow support in chattr, lsattr liubo
2015-01-02 10:22 ` Lutz Vieweg
2015-01-04 10:40 ` Erkki Seppala
2015-01-04 19:41 ` Martin Steigerwald
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).