From df76f38e95cce2ef95dbea16d14cb316cfb0639f Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Mon, 13 Apr 2020 08:35:34 -0700 Subject: [PATCH] Revert "ANDROID: Incremental fs: Fix initialization, use of bitfields" This change was never cherry-picked to other branches, is just syntactic sugar, and clashes with another change. Revert, and then apply cleanly over all branches as needed. This reverts commit 2664a43d88d91eb09f212cb26e111656a4acee49. Change-Id: I51dca9cb046cc15302c22e8f73e58dcf4849f84d Signed-off-by: Paul Lawrence --- fs/incfs/data_mgmt.c | 17 +++++++-------- fs/incfs/data_mgmt.h | 34 ++++-------------------------- include/uapi/linux/incrementalfs.h | 7 ------ 3 files changed, 12 insertions(+), 46 deletions(-) diff --git a/fs/incfs/data_mgmt.c b/fs/incfs/data_mgmt.c index caa5770f7f4c..91541b46f771 100644 --- a/fs/incfs/data_mgmt.c +++ b/fs/incfs/data_mgmt.c @@ -98,11 +98,11 @@ static void data_file_segment_destroy(struct data_file_segment *segment) struct data_file *incfs_open_data_file(struct mount_info *mi, struct file *bf) { - struct data_file *df; - struct backing_file_context *bfc; + struct data_file *df = NULL; + struct backing_file_context *bfc = NULL; int md_records; u64 size; - int error; + int error = 0; int i; if (!bf || !mi) @@ -173,7 +173,7 @@ int make_inode_ready_for_data_ops(struct mount_info *mi, struct file *backing_file) { struct inode_info *node = get_incfs_node(inode); - struct data_file *df; + struct data_file *df = NULL; int err = 0; inode_lock(inode); @@ -194,7 +194,7 @@ int make_inode_ready_for_data_ops(struct mount_info *mi, struct dir_file *incfs_open_dir_file(struct mount_info *mi, struct file *bf) { - struct dir_file *dir; + struct dir_file *dir = NULL; if (!S_ISDIR(bf->f_inode->i_mode)) return ERR_PTR(-EBADF); @@ -235,12 +235,11 @@ static void log_block_read(struct mount_info *mi, incfs_uuid_t *id, s64 now_us = ktime_to_us(ktime_get()); struct read_log_record record = { .file_id = *id, + .block_index = block_index, + .timed_out = timed_out, .timestamp_us = now_us }; - set_block_index(&record, block_index); - set_timed_out(&record, timed_out); - if (log->rl_size == 0) return; @@ -1166,7 +1165,7 @@ static void fill_pending_read_from_log_record( struct read_log_state *state, u64 log_size) { dest->file_id = src->file_id; - dest->block_index = get_block_index(src); + dest->block_index = src->block_index; dest->serial_number = state->current_pass_no * log_size + state->next_index; dest->timestamp_us = src->timestamp_us; diff --git a/fs/incfs/data_mgmt.h b/fs/incfs/data_mgmt.h index 3cdb95a7661a..e8f2154c80d9 100644 --- a/fs/incfs/data_mgmt.h +++ b/fs/incfs/data_mgmt.h @@ -21,41 +21,15 @@ #define SEGMENTS_PER_FILE 3 struct read_log_record { - u32 bitfield; + u32 block_index : 31; + + u32 timed_out : 1; u64 timestamp_us; incfs_uuid_t file_id; } __packed; -#define RLR_BLOCK_INDEX_MASK 0x7fff -#define RLR_TIMED_OUT_MASK 0x8000 - -static inline u32 get_block_index(const struct read_log_record *rlr) -{ - return rlr->bitfield & RLR_BLOCK_INDEX_MASK; -} - -static inline void set_block_index(struct read_log_record *rlr, - u32 block_index) -{ - rlr->bitfield = (rlr->bitfield & ~RLR_BLOCK_INDEX_MASK) - | (block_index & RLR_BLOCK_INDEX_MASK); -} - -static inline bool get_timed_out(const struct read_log_record *rlr) -{ - return (rlr->bitfield & RLR_TIMED_OUT_MASK) == RLR_TIMED_OUT_MASK; -} - -static inline void set_timed_out(struct read_log_record *rlr, bool timed_out) -{ - if (timed_out) - rlr->bitfield |= RLR_TIMED_OUT_MASK; - else - rlr->bitfield &= ~RLR_TIMED_OUT_MASK; -} - struct read_log_state { /* Next slot in rl_ring_buf to write to. */ u32 next_index; @@ -312,7 +286,7 @@ static inline struct inode_info *get_incfs_node(struct inode *inode) static inline struct data_file *get_incfs_data_file(struct file *f) { - struct inode_info *node; + struct inode_info *node = NULL; if (!f) return NULL; diff --git a/include/uapi/linux/incrementalfs.h b/include/uapi/linux/incrementalfs.h index ac775b64bdcf..13c3d5173e14 100644 --- a/include/uapi/linux/incrementalfs.h +++ b/include/uapi/linux/incrementalfs.h @@ -150,13 +150,10 @@ struct incfs_fill_block { /* Values from enum incfs_block_flags */ __u8 flags; - /* Reserved - must be 0 */ __u16 reserved1; - /* Reserved - must be 0 */ __u32 reserved2; - /* Reserved - must be 0 */ __aligned_u64 reserved3; }; @@ -206,10 +203,8 @@ struct incfs_new_file_args { */ __u16 mode; - /* Reserved - must be 0 */ __u16 reserved1; - /* Reserved - must be 0 */ __u32 reserved2; /* @@ -242,7 +237,6 @@ struct incfs_new_file_args { */ __u32 file_attr_len; - /* Reserved - must be 0 */ __u32 reserved4; /* @@ -270,7 +264,6 @@ struct incfs_new_file_args { /* Size of signature_info */ __aligned_u64 signature_size; - /* Reserved - must be 0 */ __aligned_u64 reserved6; };