forked from Minki/linux
udf: factor out LVID finalization for reuse
Centralize timestamping and CRC/checksum updating of the in-core Logical Volume Integrity Descriptor, in preparation for adding a third site where this functionality is needed. Signed-off-by: Steven J. Magnani <steve@digidescorp.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
1c2d14212b
commit
ebbd5e99f6
@ -1943,13 +1943,24 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void udf_finalize_lvid(struct logicalVolIntegrityDesc *lvid)
|
||||
{
|
||||
struct timespec64 ts;
|
||||
|
||||
ktime_get_real_ts64(&ts);
|
||||
udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
|
||||
lvid->descTag.descCRC = cpu_to_le16(
|
||||
crc_itu_t(0, (char *)lvid + sizeof(struct tag),
|
||||
le16_to_cpu(lvid->descTag.descCRCLength)));
|
||||
lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
|
||||
}
|
||||
|
||||
static void udf_open_lvid(struct super_block *sb)
|
||||
{
|
||||
struct udf_sb_info *sbi = UDF_SB(sb);
|
||||
struct buffer_head *bh = sbi->s_lvid_bh;
|
||||
struct logicalVolIntegrityDesc *lvid;
|
||||
struct logicalVolIntegrityDescImpUse *lvidiu;
|
||||
struct timespec64 ts;
|
||||
|
||||
if (!bh)
|
||||
return;
|
||||
@ -1961,18 +1972,12 @@ static void udf_open_lvid(struct super_block *sb)
|
||||
mutex_lock(&sbi->s_alloc_mutex);
|
||||
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
|
||||
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
|
||||
ktime_get_real_ts64(&ts);
|
||||
udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
|
||||
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),
|
||||
le16_to_cpu(lvid->descTag.descCRCLength)));
|
||||
|
||||
lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
|
||||
udf_finalize_lvid(lvid);
|
||||
mark_buffer_dirty(bh);
|
||||
sbi->s_lvid_dirty = 0;
|
||||
mutex_unlock(&sbi->s_alloc_mutex);
|
||||
@ -1986,7 +1991,6 @@ static void udf_close_lvid(struct super_block *sb)
|
||||
struct buffer_head *bh = sbi->s_lvid_bh;
|
||||
struct logicalVolIntegrityDesc *lvid;
|
||||
struct logicalVolIntegrityDescImpUse *lvidiu;
|
||||
struct timespec64 ts;
|
||||
|
||||
if (!bh)
|
||||
return;
|
||||
@ -1998,8 +2002,6 @@ static void udf_close_lvid(struct super_block *sb)
|
||||
mutex_lock(&sbi->s_alloc_mutex);
|
||||
lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
|
||||
lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
|
||||
ktime_get_real_ts64(&ts);
|
||||
udf_time_to_disk_stamp(&lvid->recordingDateAndTime, ts);
|
||||
if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev))
|
||||
lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
|
||||
if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev))
|
||||
@ -2009,17 +2011,13 @@ static void udf_close_lvid(struct super_block *sb)
|
||||
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),
|
||||
le16_to_cpu(lvid->descTag.descCRCLength)));
|
||||
|
||||
lvid->descTag.tagChecksum = udf_tag_checksum(&lvid->descTag);
|
||||
/*
|
||||
* We set buffer uptodate unconditionally here to avoid spurious
|
||||
* warnings from mark_buffer_dirty() when previous EIO has marked
|
||||
* the buffer as !uptodate
|
||||
*/
|
||||
set_buffer_uptodate(bh);
|
||||
udf_finalize_lvid(lvid);
|
||||
mark_buffer_dirty(bh);
|
||||
sbi->s_lvid_dirty = 0;
|
||||
mutex_unlock(&sbi->s_alloc_mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user