Skip to content

Commit f1f52d6

Browse files
ubifs: Introduce new data node field, compr_size
When data of a data node is compressed and encrypted we need to store the size of the compressed data because before encryption we may have to add padding bytes. For the new field we consume the last two padding bytes in struct ubifs_data_node. Two bytes are fine because the data length is at most 4096. Signed-off-by: Richard Weinberger <[email protected]>
1 parent 959c2de commit f1f52d6

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

fs/ubifs/journal.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ static inline void zero_dent_node_unused(struct ubifs_dent_node *dent)
8181
memset(dent->padding2, 0, 4);
8282
}
8383

84-
/**
85-
* zero_data_node_unused - zero out unused fields of an on-flash data node.
86-
* @data: the data node to zero out
87-
*/
88-
static inline void zero_data_node_unused(struct ubifs_data_node *data)
89-
{
90-
memset(data->padding, 0, 2);
91-
}
92-
9384
/**
9485
* zero_trun_node_unused - zero out unused fields of an on-flash truncation
9586
* node.
@@ -722,7 +713,6 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
722713
data->ch.node_type = UBIFS_DATA_NODE;
723714
key_write(c, key, &data->key);
724715
data->size = cpu_to_le32(len);
725-
zero_data_node_unused(data);
726716

727717
if (!(ui->flags & UBIFS_COMPR_FL))
728718
/* Compression is disabled for this inode */
@@ -1357,7 +1347,6 @@ int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode,
13571347
dn->size = cpu_to_le32(dlen);
13581348
dlen += UBIFS_DATA_NODE_SZ;
13591349
}
1360-
zero_data_node_unused(dn);
13611350
}
13621351
}
13631352
}

fs/ubifs/ubifs-media.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,18 +553,16 @@ struct ubifs_dent_node {
553553
* @key: node key
554554
* @size: uncompressed data size in bytes
555555
* @compr_type: compression type (%UBIFS_COMPR_NONE, %UBIFS_COMPR_LZO, etc)
556-
* @padding: reserved for future, zeroes
556+
* @compr_size: compressed data size in bytes, only valid when data is encrypted
557557
* @data: data
558558
*
559-
* Note, do not forget to amend 'zero_data_node_unused()' function when
560-
* changing the padding fields.
561559
*/
562560
struct ubifs_data_node {
563561
struct ubifs_ch ch;
564562
__u8 key[UBIFS_MAX_KEY_LEN];
565563
__le32 size;
566564
__le16 compr_type;
567-
__u8 padding[2]; /* Watch 'zero_data_node_unused()' if changing! */
565+
__le16 compr_size;
568566
__u8 data[];
569567
} __packed;
570568

0 commit comments

Comments
 (0)