All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] udf: Do not mark possibly inconsistent filesystems as closed
@ 2018-02-28 11:22 Jan Kara
  2018-02-28 21:58 ` Pali Rohár
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kara @ 2018-02-28 11:22 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Pali Rohár, Jan Kara

If logical volume integrity descriptor contains non-closed integrity
type when mounting the volume, there are high chances that the volume is
not consistent (device was detached before the filesystem was
unmounted). Warn when mounting such volume and don't touch integrity
type of the volume so that fsck can recognize it and check such
filesystem.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/udf/super.c  | 8 ++++++--
 fs/udf/udf_sb.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 2d4929fa884d..bf5f6084dcb2 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1988,7 +1988,10 @@ static void udf_open_lvid(struct super_block *sb)
 	lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
 	ktime_get_real_ts(&ts);
 	udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
-	lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
+	if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE)
+		lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
+	else
+		UDF_SET_FLAG(sb, UDF_FLAG_INCONSISTENT);
 
 	lvid->descTag.descCRC = cpu_to_le16(
 		crc_itu_t(0, (char *)lvid + sizeof(struct tag),
@@ -2028,7 +2031,8 @@ static void udf_close_lvid(struct super_block *sb)
 		lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev);
 	if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev))
 		lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev);
-	lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
+	if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT))
+		lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
 
 	lvid->descTag.descCRC = cpu_to_le16(
 			crc_itu_t(0, (char *)lvid + sizeof(struct tag),
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 9dcb475fc74e..9dd3e1b9619e 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -29,6 +29,7 @@
 #define UDF_FLAG_SESSION_SET	15
 #define UDF_FLAG_LASTBLOCK_SET	16
 #define UDF_FLAG_BLOCKSIZE_SET	17
+#define UDF_FLAG_INCONSISTENT	18
 
 #define UDF_PART_FLAG_UNALLOC_BITMAP	0x0001
 #define UDF_PART_FLAG_UNALLOC_TABLE	0x0002
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] udf: Do not mark possibly inconsistent filesystems as closed
  2018-02-28 11:22 [PATCH] udf: Do not mark possibly inconsistent filesystems as closed Jan Kara
@ 2018-02-28 21:58 ` Pali Rohár
  2018-03-01 12:33   ` Jan Kara
  0 siblings, 1 reply; 4+ messages in thread
From: Pali Rohár @ 2018-02-28 21:58 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel

[-- Attachment #1: Type: text/plain, Size: 2385 bytes --]

On Wednesday 28 February 2018 12:22:55 Jan Kara wrote:
> If logical volume integrity descriptor contains non-closed integrity
> type when mounting the volume, there are high chances that the volume is
> not consistent (device was detached before the filesystem was
> unmounted). Warn when mounting such volume and don't touch integrity

Need to edit commit message as there is no warning in patch...

> type of the volume so that fsck can recognize it and check such
> filesystem.
> 
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  fs/udf/super.c  | 8 ++++++--
>  fs/udf/udf_sb.h | 1 +
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 2d4929fa884d..bf5f6084dcb2 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -1988,7 +1988,10 @@ static void udf_open_lvid(struct super_block *sb)
>  	lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
>  	ktime_get_real_ts(&ts);
>  	udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
> -	lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
> +	if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE)
> +		lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
> +	else
> +		UDF_SET_FLAG(sb, UDF_FLAG_INCONSISTENT);
>  
>  	lvid->descTag.descCRC = cpu_to_le16(
>  		crc_itu_t(0, (char *)lvid + sizeof(struct tag),
> @@ -2028,7 +2031,8 @@ static void udf_close_lvid(struct super_block *sb)
>  		lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev);
>  	if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev))
>  		lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev);
> -	lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
> +	if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT))
> +		lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
>  
>  	lvid->descTag.descCRC = cpu_to_le16(
>  			crc_itu_t(0, (char *)lvid + sizeof(struct tag),
> diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
> index 9dcb475fc74e..9dd3e1b9619e 100644
> --- a/fs/udf/udf_sb.h
> +++ b/fs/udf/udf_sb.h
> @@ -29,6 +29,7 @@
>  #define UDF_FLAG_SESSION_SET	15
>  #define UDF_FLAG_LASTBLOCK_SET	16
>  #define UDF_FLAG_BLOCKSIZE_SET	17
> +#define UDF_FLAG_INCONSISTENT	18
>  
>  #define UDF_PART_FLAG_UNALLOC_BITMAP	0x0001
>  #define UDF_PART_FLAG_UNALLOC_TABLE	0x0002

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] udf: Do not mark possibly inconsistent filesystems as closed
  2018-02-28 21:58 ` Pali Rohár
@ 2018-03-01 12:33   ` Jan Kara
  2018-03-01 17:26     ` Pali Rohár
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kara @ 2018-03-01 12:33 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Jan Kara, linux-fsdevel

On Wed 28-02-18 22:58:38, Pali Roh�r wrote:
> On Wednesday 28 February 2018 12:22:55 Jan Kara wrote:
> > If logical volume integrity descriptor contains non-closed integrity
> > type when mounting the volume, there are high chances that the volume is
> > not consistent (device was detached before the filesystem was
> > unmounted). Warn when mounting such volume and don't touch integrity
> 
> Need to edit commit message as there is no warning in patch...

Good point. Fixed and pushed to my tree. Can I add your Reviewed-by tag?

								Honza

> 
> > type of the volume so that fsck can recognize it and check such
> > filesystem.
> > 
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> >  fs/udf/super.c  | 8 ++++++--
> >  fs/udf/udf_sb.h | 1 +
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/udf/super.c b/fs/udf/super.c
> > index 2d4929fa884d..bf5f6084dcb2 100644
> > --- a/fs/udf/super.c
> > +++ b/fs/udf/super.c
> > @@ -1988,7 +1988,10 @@ static void udf_open_lvid(struct super_block *sb)
> >  	lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
> >  	ktime_get_real_ts(&ts);
> >  	udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
> > -	lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
> > +	if (le32_to_cpu(lvid->integrityType) == LVID_INTEGRITY_TYPE_CLOSE)
> > +		lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN);
> > +	else
> > +		UDF_SET_FLAG(sb, UDF_FLAG_INCONSISTENT);
> >  
> >  	lvid->descTag.descCRC = cpu_to_le16(
> >  		crc_itu_t(0, (char *)lvid + sizeof(struct tag),
> > @@ -2028,7 +2031,8 @@ static void udf_close_lvid(struct super_block *sb)
> >  		lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev);
> >  	if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev))
> >  		lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev);
> > -	lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
> > +	if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT))
> > +		lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
> >  
> >  	lvid->descTag.descCRC = cpu_to_le16(
> >  			crc_itu_t(0, (char *)lvid + sizeof(struct tag),
> > diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
> > index 9dcb475fc74e..9dd3e1b9619e 100644
> > --- a/fs/udf/udf_sb.h
> > +++ b/fs/udf/udf_sb.h
> > @@ -29,6 +29,7 @@
> >  #define UDF_FLAG_SESSION_SET	15
> >  #define UDF_FLAG_LASTBLOCK_SET	16
> >  #define UDF_FLAG_BLOCKSIZE_SET	17
> > +#define UDF_FLAG_INCONSISTENT	18
> >  
> >  #define UDF_PART_FLAG_UNALLOC_BITMAP	0x0001
> >  #define UDF_PART_FLAG_UNALLOC_TABLE	0x0002
> 
> -- 
> Pali Roh�r
> pali.rohar@gmail.com


-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] udf: Do not mark possibly inconsistent filesystems as closed
  2018-03-01 12:33   ` Jan Kara
@ 2018-03-01 17:26     ` Pali Rohár
  0 siblings, 0 replies; 4+ messages in thread
From: Pali Rohár @ 2018-03-01 17:26 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-fsdevel

On Thursday 01 March 2018 13:33:08 Jan Kara wrote:
> On Wed 28-02-18 22:58:38, Pali Rohár wrote:
> > On Wednesday 28 February 2018 12:22:55 Jan Kara wrote:
> > > If logical volume integrity descriptor contains non-closed integrity
> > > type when mounting the volume, there are high chances that the volume is
> > > not consistent (device was detached before the filesystem was
> > > unmounted). Warn when mounting such volume and don't touch integrity
> > 
> > Need to edit commit message as there is no warning in patch...
> 
> Good point. Fixed and pushed to my tree. Can I add your Reviewed-by tag?

Yes!

-- 
Pali Rohár
pali.rohar@gmail.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-01 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28 11:22 [PATCH] udf: Do not mark possibly inconsistent filesystems as closed Jan Kara
2018-02-28 21:58 ` Pali Rohár
2018-03-01 12:33   ` Jan Kara
2018-03-01 17:26     ` Pali Rohár

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.