diff options
author | Kari Argillander <kari.argillander@gmail.com> | 2021-08-03 14:57:09 +0300 |
---|---|---|
committer | Konstantin Komarov <almaz.alexandrovich@paragon-software.com> | 2021-08-30 18:39:14 +0300 |
commit | e8b8e97f91b80f08a2f1b7ea4f81e7af61b2cc2f (patch) | |
tree | dfa9cd09534c9d3f495a4bd5c36fd182856810be /fs/ntfs3/fslog.c | |
parent | b8155e95de38b25a69dfb03e4731fd6c5a28531e (diff) | |
download | linux-e8b8e97f91b80f08a2f1b7ea4f81e7af61b2cc2f.tar.xz |
fs/ntfs3: Restyle comments to better align with kernel-doc
Capitalize comments and end with period for better reading.
Also function comments are now little more kernel-doc style. This way we
can easily convert them to kernel-doc style if we want. Note that these
are not yet complete with this style. Example function comments start
with /* and in kernel-doc style they start /**.
Use imperative mood in function descriptions.
Change words like ntfs -> NTFS, linux -> Linux.
Use "we" not "I" when commenting code.
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Diffstat (limited to 'fs/ntfs3/fslog.c')
-rw-r--r-- | fs/ntfs3/fslog.c | 728 |
1 files changed, 373 insertions, 355 deletions
diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c index 7144ea8a9ab8..6f6057129fdd 100644 --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -30,8 +30,8 @@ struct RESTART_HDR { struct NTFS_RECORD_HEADER rhdr; // 'RSTR' - __le32 sys_page_size; // 0x10: Page size of the system which initialized the log - __le32 page_size; // 0x14: Log page size used for this log file + __le32 sys_page_size; // 0x10: Page size of the system which initialized the log. + __le32 page_size; // 0x14: Log page size used for this log file. __le16 ra_off; // 0x18: __le16 minor_ver; // 0x1A: __le16 major_ver; // 0x1C: @@ -47,26 +47,26 @@ struct CLIENT_REC { __le16 prev_client; // 0x10: __le16 next_client; // 0x12: __le16 seq_num; // 0x14: - u8 align[6]; // 0x16 - __le32 name_bytes; // 0x1C: in bytes - __le16 name[32]; // 0x20: name of client + u8 align[6]; // 0x16: + __le32 name_bytes; // 0x1C: In bytes. + __le16 name[32]; // 0x20: Name of client. }; static_assert(sizeof(struct CLIENT_REC) == 0x60); /* Two copies of these will exist at the beginning of the log file */ struct RESTART_AREA { - __le64 current_lsn; // 0x00: Current logical end of log file - __le16 log_clients; // 0x08: Maximum number of clients - __le16 client_idx[2]; // 0x0A: free/use index into the client record arrays - __le16 flags; // 0x0E: See RESTART_SINGLE_PAGE_IO - __le32 seq_num_bits; // 0x10: the number of bits in sequence number. + __le64 current_lsn; // 0x00: Current logical end of log file. + __le16 log_clients; // 0x08: Maximum number of clients. + __le16 client_idx[2]; // 0x0A: Free/use index into the client record arrays. + __le16 flags; // 0x0E: See RESTART_SINGLE_PAGE_IO. + __le32 seq_num_bits; // 0x10: The number of bits in sequence number. __le16 ra_len; // 0x14: __le16 client_off; // 0x16: __le64 l_size; // 0x18: Usable log file size. __le32 last_lsn_data_len; // 0x20: - __le16 rec_hdr_len; // 0x24: log page data offset - __le16 data_off; // 0x26: log page data length + __le16 rec_hdr_len; // 0x24: Log page data offset. + __le16 data_off; // 0x26: Log page data length. __le32 open_log_count; // 0x28: __le32 align[5]; // 0x2C: struct CLIENT_REC clients[]; // 0x40: @@ -75,10 +75,10 @@ struct RESTART_AREA { struct LOG_REC_HDR { __le16 redo_op; // 0x00: NTFS_LOG_OPERATION __le16 undo_op; // 0x02: NTFS_LOG_OPERATION - __le16 redo_off; // 0x04: Offset to Redo record - __le16 redo_len; // 0x06: Redo length - __le16 undo_off; // 0x08: Offset to Undo record - __le16 undo_len; // 0x0A: Undo length + __le16 redo_off; // 0x04: Offset to Redo record. + __le16 redo_len; // 0x06: Redo length. + __le16 undo_off; // 0x08: Offset to Undo record. + __le16 undo_len; // 0x0A: Undo length. __le16 target_attr; // 0x0C: __le16 lcns_follow; // 0x0E: __le16 record_off; // 0x10: @@ -95,20 +95,20 @@ static_assert(sizeof(struct LOG_REC_HDR) == 0x20); #define RESTART_ENTRY_ALLOCATED_LE cpu_to_le32(0xFFFFFFFF) struct RESTART_TABLE { - __le16 size; // 0x00: In bytes - __le16 used; // 0x02: entries - __le16 total; // 0x04: entries + __le16 size; // 0x00: In bytes + __le16 used; // 0x02: Entries + __le16 total; // 0x04: Entries __le16 res[3]; // 0x06: __le32 free_goal; // 0x0C: - __le32 first_free; // 0x10 - __le32 last_free; // 0x14 + __le32 first_free; // 0x10: + __le32 last_free; // 0x14: }; static_assert(sizeof(struct RESTART_TABLE) == 0x18); struct ATTR_NAME_ENTRY { - __le16 off; // offset in the Open attribute Table + __le16 off; // Offset in the Open attribute Table. __le16 name_bytes; __le16 name[]; }; @@ -121,7 +121,7 @@ struct OPEN_ATTR_ENRTY { u8 is_attr_name; // 0x0B: Faked field to manage 'ptr' u8 name_len; // 0x0C: Faked field to manage 'ptr' u8 res; - struct MFT_REF ref; // 0x10: File Reference of file containing attribute + struct MFT_REF ref; // 0x10: File Reference of file containing attribute __le64 open_record_lsn; // 0x18: void *ptr; // 0x20: }; @@ -133,10 +133,10 @@ struct OPEN_ATTR_ENRTY_32 { struct MFT_REF ref; // 0x08: __le64 open_record_lsn; // 0x10: u8 is_dirty_pages; // 0x18: - u8 is_attr_name; // 0x19 + u8 is_attr_name; // 0x19: u8 res1[2]; enum ATTR_TYPE type; // 0x1C: - u8 name_len; // 0x20: in wchar + u8 name_len; // 0x20: In wchar u8 res2[3]; __le32 AttributeName; // 0x24: __le32 bytes_per_index; // 0x28: @@ -147,15 +147,15 @@ struct OPEN_ATTR_ENRTY_32 { static_assert(sizeof(struct OPEN_ATTR_ENRTY) < SIZEOF_OPENATTRIBUTEENTRY0); /* - * One entry exists in the Dirty Pages Table for each page which is dirty at the - * time the Restart Area is written + * One entry exists in the Dirty Pages Table for each page which is dirty at + * the time the Restart Area is written. */ struct DIR_PAGE_ENTRY { - __le32 next; // 0x00: RESTART_ENTRY_ALLOCATED if allocated - __le32 target_attr; // 0x04: Index into the Open attribute Table + __le32 next; // 0x00: RESTART_ENTRY_ALLOCATED if allocated + __le32 target_attr; // 0x04: Index into the Open attribute Table __le32 transfer_len; // 0x08: __le32 lcns_follow; // 0x0C: - __le64 vcn; // 0x10: Vcn of dirty page + __le64 vcn; // 0x10: Vcn of dirty page __le64 oldest_lsn; // 0x18: __le64 page_lcns[]; // 0x20: }; @@ -164,17 +164,17 @@ static_assert(sizeof(struct DIR_PAGE_ENTRY) == 0x20); /* 32 bit version of 'struct DIR_PAGE_ENTRY' */ struct DIR_PAGE_ENTRY_32 { - __le32 next; // 0x00: RESTART_ENTRY_ALLOCATED if allocated - __le32 target_attr; // 0x04: Index into the Open attribute Table - __le32 transfer_len; // 0x08: - __le32 lcns_follow; // 0x0C: - __le32 reserved; // 0x10: - __le32 vcn_low; // 0x14: Vcn of dirty page - __le32 vcn_hi; // 0x18: Vcn of dirty page - __le32 oldest_lsn_low; // 0x1C: - __le32 oldest_lsn_hi; // 0x1C: - __le32 page_lcns_low; // 0x24: - __le32 page_lcns_hi; // 0x24: + __le32 next; // 0x00: RESTART_ENTRY_ALLOCATED if allocated + __le32 target_attr; // 0x04: Index into the Open attribute Table + __le32 transfer_len; // 0x08: + __le32 lcns_follow; // 0x0C: + __le32 reserved; // 0x10: + __le32 vcn_low; // 0x14: Vcn of dirty page + __le32 vcn_hi; // 0x18: Vcn of dirty page + __le32 oldest_lsn_low; // 0x1C: + __le32 oldest_lsn_hi; // 0x1C: + __le32 page_lcns_low; // 0x24: + __le32 page_lcns_hi; // 0x24: }; static_assert(offsetof(struct DIR_PAGE_ENTRY_32, vcn_low) == 0x14); @@ -233,27 +233,27 @@ struct LCN_RANGE { __le64 len; }; -/* The following type defines the different log record types */ +/* The following type defines the different log record types. */ #define LfsClientRecord cpu_to_le32(1) #define LfsClientRestart cpu_to_le32(2) -/* This is used to uniquely identify a client for a particular log file */ +/* This is used to uniquely identify a client for a particular log file. */ struct CLIENT_ID { __le16 seq_num; __le16 client_idx; }; -/* This is the header that begins every Log Record in the log file */ +/* This is the header that begins every Log Record in the log file. */ struct LFS_RECORD_HDR { - __le64 this_lsn; // 0x00: - __le64 client_prev_lsn; // 0x08: - __le64 client_undo_next_lsn; // 0x10: - __le32 client_data_len; // 0x18: - struct CLIENT_ID client; // 0x1C: Owner of this log record - __le32 record_type; // 0x20: LfsClientRecord or LfsClientRestart - __le32 transact_id; // 0x24: - __le16 flags; // 0x28: LOG_RECORD_MULTI_PAGE - u8 align[6]; // 0x2A: + __le64 this_lsn; // 0x00: + __le64 client_prev_lsn; // 0x08: + __le64 client_undo_next_lsn; // 0x10: + __le32 client_data_len; // 0x18: + struct CLIENT_ID client; // 0x1C: Owner of this log record. + __le32 record_type; // 0x20: LfsClientRecord or LfsClientRestart. + __le32 transact_id; // 0x24: + __le16 flags; // 0x28: LOG_RECORD_MULTI_PAGE + u8 align[6]; // 0x2A: }; #define LOG_RECORD_MULTI_PAGE cpu_to_le16(1) @@ -261,26 +261,26 @@ struct LFS_RECORD_HDR { static_assert(sizeof(struct LFS_RECORD_HDR) == 0x30); struct LFS_RECORD { - __le16 next_record_off; // 0x00: Offset of the free space in the page - u8 align[6]; // 0x02: - __le64 last_end_lsn; // 0x08: lsn for the last log record which ends on the page + __le16 next_record_off; // 0x00: Offset of the free space in the page, + u8 align[6]; // 0x02: + __le64 last_end_lsn; // 0x08: lsn for the last log record which ends on the page, }; static_assert(sizeof(struct LFS_RECORD) == 0x10); struct RECORD_PAGE_HDR { - struct NTFS_RECORD_HEADER rhdr; // 'RCRD' - __le32 rflags; // 0x10: See LOG_PAGE_LOG_RECORD_END - __le16 page_count; // 0x14: - __le16 page_pos; // 0x16: - struct LFS_RECORD record_hdr; // 0x18 - __le16 fixups[10]; // 0x28 - __le32 file_off; // 0x3c: used when major version >= 2 + struct NTFS_RECORD_HEADER rhdr; // 'RCRD' + __le32 rflags; // 0x10: See LOG_PAGE_LOG_RECORD_END + __le16 page_count; // 0x14: + __le16 page_pos; // 0x16: + struct LFS_RECORD record_hdr; // 0x18: + __le16 fixups[10]; // 0x28: + __le32 file_off; // 0x3c: Used when major version >= 2 }; // clang-format on -// Page contains the end of a log record +// Page contains the end of a log record. #define LOG_PAGE_LOG_RECORD_END cpu_to_le32(0x00000001) static inline bool is_log_record_end(const struct RECORD_PAGE_HDR *hdr) @@ -294,7 +294,7 @@ static_assert(offsetof(struct RECORD_PAGE_HDR, file_off) == 0x3c); * END of NTFS LOG structures */ -/* Define some tuning parameters to keep the restart tables a reasonable size */ +/* Define some tuning parameters to keep the restart tables a reasonable size. */ #define INITIAL_NUMBER_TRANSACTIONS 5 enum NTFS_LOG_OPERATION { @@ -342,8 +342,9 @@ enum NTFS_LOG_OPERATION { }; /* - * Array for log records which require a target attribute - * A true indicates that the corresponding restart operation requires a target attribute + * Array for log records which require a target attribute. + * A true indicates that the corresponding restart operation + * requires a target attribute. */ static const u8 AttributeRequired[] = { 0xFC, 0xFB, 0xFF, 0x10, 0x06, @@ -380,14 +381,14 @@ static inline bool can_skip_action(enum NTFS_LOG_OPERATION op) enum { lcb_ctx_undo_next, lcb_ctx_prev, lcb_ctx_next }; -/* bytes per restart table */ +/* Bytes per restart table. */ static inline u32 bytes_per_rt(const struct RESTART_TABLE *rt) { return le16_to_cpu(rt->used) * le16_to_cpu(rt->size) + sizeof(struct RESTART_TABLE); } -/* log record length */ +/* Log record length. */ static inline u32 lrh_length(const struct LOG_REC_HDR *lr) { u16 t16 = le16_to_cpu(lr->lcns_follow); @@ -396,11 +397,11 @@ static inline u32 lrh_length(const struct LOG_REC_HDR *lr) } struct lcb { - struct LFS_RECORD_HDR *lrh; // Log record header of the current lsn + struct LFS_RECORD_HDR *lrh; // Log record header of the current lsn. struct LOG_REC_HDR *log_rec; u32 ctx_mode; // lcb_ctx_undo_next/lcb_ctx_prev/lcb_ctx_next struct CLIENT_ID client; - bool alloc; // if true the we should deallocate 'log_rec' + bool alloc; // If true the we should deallocate 'log_rec'. }; static void lcb_put(struct lcb *lcb) @@ -411,11 +412,7 @@ static void lcb_put(struct lcb *lcb) kfree(lcb); } -/* - * oldest_client_lsn - * - * find the oldest lsn from active clients. - */ +/* Find the oldest lsn from active clients. */ static inline void oldest_client_lsn(const struct CLIENT_REC *ca, __le16 next_client, u64 *oldest_lsn) { @@ -423,7 +420,7 @@ static inline void oldest_client_lsn(const struct CLIENT_REC *ca, const struct CLIENT_REC *cr = ca + le16_to_cpu(next_client); u64 lsn = le64_to_cpu(cr->oldest_lsn); - /* ignore this block if it's oldest lsn is 0 */ + /* Ignore this block if it's oldest lsn is 0. */ if (lsn && lsn < *oldest_lsn) *oldest_lsn = lsn; @@ -444,11 +441,11 @@ static inline bool is_rst_page_hdr_valid(u32 file_off, return false; } - /* Check that if the file offset isn't 0, it is the system page size */ + /* Check that if the file offset isn't 0, it is the system page size. */ if (file_off && file_off != sys_page) return false; - /* Check support version 1.1+ */ + /* Check support version 1.1+. */ if (le16_to_cpu(rhdr->major_ver) <= 1 && !rhdr->minor_ver) return false; @@ -498,7 +495,7 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr) /* * Check the restart length field and whether the entire - * restart area is contained that length + * restart area is contained that length. */ if (le16_to_cpu(rhdr->ra_off) + le16_to_cpu(ra->ra_len) > sys_page || off > le16_to_cpu(ra->ra_len)) { @@ -507,7 +504,7 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr) /* * As a final check make sure that the use list and the free list - * are either empty or point to a valid client + * are either empty or point to a valid client. */ fl = le16_to_cpu(ra->client_idx[0]); ul = le16_to_cpu(ra->client_idx[1]); @@ -515,7 +512,7 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr) (ul != LFS_NO_CLIENT && ul >= cl)) return false; - /* Make sure the sequence number bits match the log file size */ + /* Make sure the sequence number bits match the log file size. */ l_size = le64_to_cpu(ra->l_size); file_dat_bits = sizeof(u64) * 8 - le32_to_cpu(ra->seq_num_bits); @@ -525,7 +522,7 @@ static inline bool is_rst_area_valid(const struct RESTART_HDR *rhdr) return false; } - /* The log page data offset and record header length must be quad-aligned */ + /* The log page data offset and record header length must be quad-aligned. */ if (!IS_ALIGNED(le16_to_cpu(ra->data_off), 8) || !IS_ALIGNED(le16_to_cpu(ra->rec_hdr_len), 8)) return false; @@ -545,13 +542,13 @@ static inline bool is_client_area_valid(const struct RESTART_HDR *rhdr, if (usa_error && ra_len + ro > SECTOR_SIZE - sizeof(short)) return false; - /* Find the start of the client array */ + /* Find the start of the client array. */ ca = Add2Ptr(ra, le16_to_cpu(ra->client_off)); /* - * Start with the free list - * Check that all the clients are valid and that there isn't a cycle - * Do the in-use list on the second pass + * Start with the free list. + * Check that all the clients are valid and that there isn't a cycle. + * Do the in-use list on the second pass. */ for (i = 0; i < 2; i++) { u16 client_idx = le16_to_cpu(ra->client_idx[i]); @@ -584,7 +581,7 @@ static inline bool is_client_area_valid(const struct RESTART_HDR *rhdr, /* * remove_client * - * remove a client record from a client record list an restart area + * Remove a client record from a client record list an restart area. */ static inline void remove_client(struct CLIENT_REC *ca, const struct CLIENT_REC *cr, __le16 *head) @@ -599,9 +596,7 @@ static inline void remove_client(struct CLIENT_REC *ca, } /* - * add_client - * - * add a client record to the start of a list + * add_client - Add a client record to the start of a list. */ static inline void add_client(struct CLIENT_REC *ca, u16 index, __le16 *head) { @@ -616,10 +611,6 @@ static inline void add_client(struct CLIENT_REC *ca, u16 index, __le16 *head) *head = cpu_to_le16(index); } -/* - * enum_rstbl - * - */ static inline void *enum_rstbl(struct RESTART_TABLE *t, void *c) { __le32 *e; @@ -634,7 +625,7 @@ static inline void *enum_rstbl(struct RESTART_TABLE *t, void *c) e = Add2Ptr(c, rsize); } - /* Loop until we hit the first one allocated, or the end of the list */ + /* Loop until we hit the first one allocated, or the end of the list. */ for (bprt = bytes_per_rt(t); PtrOffset(t, e) < bprt; e = Add2Ptr(e, rsize)) { if (*e == RESTART_ENTRY_ALLOCATED_LE) @@ -644,9 +635,7 @@ static inline void *enum_rstbl(struct RESTART_TABLE *t, void *c) } /* - * find_dp - * - * searches for a 'vcn' in Dirty Page Table, + * find_dp - Search for a @vcn in Dirty Page Table. */ static inline struct DIR_PAGE_ENTRY *find_dp(struct RESTART_TABLE *dptbl, u32 target_attr, u64 vcn) @@ -670,10 +659,10 @@ static inline u32 norm_file_page(u32 page_size, u32 *l_size, bool use_default) if (use_default) page_size = DefaultLogPageSize; - /* Round the file size down to a system page boundary */ + /* Round the file size down to a system page boundary. */ *l_size &= ~(page_size - 1); - /* File should contain at least 2 restart pages and MinLogRecordPages pages */ + /* File should contain at least 2 restart pages and MinLogRecordPages pages. */ if (*l_size < (MinLogRecordPages + 2) * page_size) return 0; @@ -743,8 +732,9 @@ static bool check_rstbl(const struct RESTART_TABLE *rt, size_t bytes) return false; } - /* Verify each entry is either allocated or points - * to a valid offset the table + /* + * Verify each entry is either allocated or points + * to a valid offset the table. */ for (i = 0; i < ne; i++) { off = le32_to_cpu(*(__le32 *)Add2Ptr( @@ -757,8 +747,9 @@ static bool check_rstbl(const struct RESTART_TABLE *rt, size_t bytes) } } - /* Walk through the list headed by the first entry to make - * sure none of the entries are currently being used + /* + * Walk through the list headed by the first entry to make + * sure none of the entries are currently being used. */ for (off = ff; off;) { if (off == RESTART_ENTRY_ALLOCATED) @@ -771,9 +762,7 @@ static bool check_rstbl(const struct RESTART_TABLE *rt, size_t bytes) } /* - * free_rsttbl_idx - * - * frees a previously allocated index a Restart Table. + * free_rsttbl_idx - Free a previously allocated index a Restart Table. */ static inline void free_rsttbl_idx(struct RESTART_TABLE *rt, u32 off) { @@ -863,7 +852,7 @@ static inline struct RESTART_TABLE *extend_rsttbl(struct RESTART_TABLE *tbl, /* * alloc_rsttbl_idx * - * allocates an index from within a previously initialized Restart Table + * Allocate an index from within a previously initialized Restart Table. */ static inline void *alloc_rsttbl_idx(struct RESTART_TABLE **tbl) { @@ -900,7 +889,7 @@ static inline void *alloc_rsttbl_idx(struct RESTART_TABLE **tbl) /* * alloc_rsttbl_from_idx * - * allocates a specific index from within a previously initialized Restart Table + * Allocate a specific index from within a previously initialized Restart Table. */ static inline void *alloc_rsttbl_from_idx(struct RESTART_TABLE **tbl, u32 vbo) { @@ -910,23 +899,24 @@ static inline void *alloc_rsttbl_from_idx(struct RESTART_TABLE **tbl, u32 vbo) u32 bytes = bytes_per_rt(rt); u16 esize = le16_to_cpu(rt->size); - /* If the entry is not the table, we will have to extend the table */ + /* If the entry is not the table, we will have to extend the table. */ if (vbo >= bytes) { /* - * extend the size by computing the number of entries between - * the existing size and the desired index and adding - * 1 to that + * Extend the size by computing the number of entries between + * the existing size and the desired index and adding 1 to that. */ u32 bytes2idx = vbo - bytes; - /* There should always be an integral number of entries being added */ - /* Now extend the table */ + /* + * There should always be an integral number of entries + * being added. Now extend the table. + */ *tbl = rt = extend_rsttbl(rt, bytes2idx / esize + 1, bytes); if (!rt) return NULL; } - /* see if the entry is already allocated, and just return if it is. */ + /* See if the entry is already allocated, and just return if it is. */ e = Add2Ptr(rt, vbo); if (*e == RESTART_ENTRY_ALLOCATED_LE) @@ -934,7 +924,7 @@ static inline void *alloc_rsttbl_from_idx(struct RESTART_TABLE **tbl, u32 vbo) /* * Walk through the table, looking for the entry we're - * interested and the previous entry + * interested and the previous entry. */ off = le32_to_cpu(rt->first_free); e = Add2Ptr(rt, off); @@ -946,24 +936,28 @@ static inline void *alloc_rsttbl_from_idx(struct RESTART_TABLE **tbl, u32 vbo) } /* - * need to walk through the list looking for the predecessor of our entry + * Need to walk through the list looking for the predecessor + * of our entry. */ for (;;) { /* Remember the entry just found */ u32 last_off = off; __le32 *last_e = e; - /* should never run of entries. */ + /* Should never run of entries. */ - /* Lookup up the next entry the list */ + /* Lookup up the next entry the list. */ off = le32_to_cpu(*last_e); e = Add2Ptr(rt, off); - /* If this is our match we are done */ + /* If this is our match we are done. */ if (off == vbo) { *last_e = *e; - /* If this was the last entry, we update that the table as well */ + /* + * If this was the last entry, we update that + * table as well. + */ if (le32_to_cpu(rt->last_free) == off) rt->last_free = cpu_to_le32(last_off); break; @@ -971,11 +965,11 @@ static inline void *alloc_rsttbl_from_idx(struct RESTART_TABLE **tbl, u32 vbo) } skip_looking: - /* If the list is now empty, we fix the last_free as well */ + /* If the list is now empty, we fix the last_free as well. */ if (!rt->first_free) rt->last_free = 0; - /* Zero this entry */ + /* Zero this entry. */ memset(e, 0, esize); *e = RESTART_ENTRY_ALLOCATED_LE; @@ -992,9 +986,7 @@ skip_looking: #define NTFSLOG_REUSE_TAIL 0x00000010 #define NTFSLOG_NO_OLDEST_LSN 0x00000020 -/* - * Helper struct to work with NTFS LogFile - */ +/* Helper struct to work with NTFS $LogFile. */ struct ntfs_log { struct ntfs_inode *ni; @@ -1022,15 +1014,15 @@ struct ntfs_log { u32 file_data_bits; u32 seq_num_mask; /* (1 << file_data_bits) - 1 */ - struct RESTART_AREA *ra; /* in-memory image of the next restart area */ - u32 ra_size; /* the usable size of the restart area */ + struct RESTART_AREA *ra; /* In-memory image of the next restart area. */ + u32 ra_size; /* The usable size of the restart area. */ /* * If true, then the in-memory restart area is to be written - * to the first position on the disk + * to the first position on the disk. */ bool init_ra; - bool set_dirty; /* true if we need to set dirty flag */ + bool set_dirty; /* True if we need to set dirty flag. */ u64 oldest_lsn; @@ -1048,7 +1040,7 @@ struct ntfs_log { short minor_ver; u32 l_flags; /* See NTFSLOG_XXX */ - u32 current_openlog_count; /* On-disk value for open_log_count */ + u32 current_openlog_count; /* On-disk value for open_log_count. */ struct CLIENT_ID client_id; u32 client_undo_commit; @@ -1061,7 +1053,7 @@ static inline u32 lsn_to_vbo(struct ntfs_log *log, const u64 lsn) return vbo; } -/* compute the offset in the log file of the next log page */ +/* Compute the offset in the log file of the next log page. */ static inline u32 next_page_off(struct ntfs_log *log, u32 off) { off = (off & ~log->sys_page_mask) + log->page_size; @@ -1184,8 +1176,9 @@ out: /* * log_read_rst * - * it walks through 512 blocks of the file looking for a valid restart page header - * It will stop the first time we find a valid page header + * It walks through 512 blocks of the file looking for a valid + * restart page header. It will stop the first time we find a + * valid page header. */ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first, struct restart_info *info) @@ -1198,7 +1191,7 @@ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first, memset(info, 0, sizeof(struct restart_info)); - /* Determine which restart area we are looking for */ + /* Determine which restart area we are looking for. */ if (first) { vbo = 0; skip = 512; @@ -1207,21 +1200,21 @@ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first, skip = 0; } - /* loop continuously until we succeed */ + /* Loop continuously until we succeed. */ for (; vbo < l_size; vbo = 2 * vbo + skip, skip = 0) { bool usa_error; u32 sys_page_size; bool brst, bchk; struct RESTART_AREA *ra; - /* Read a page header at the current offset */ + /* Read a page header at the current offset. */ if (read_log_page(log, vbo, (struct RECORD_PAGE_HDR **)&r_page, &usa_error)) { - /* ignore any errors */ + /* Ignore any errors. */ continue; } - /* exit if the signature is a log record page */ + /* Exit if the signature is a log record page. */ if (r_page->rhdr.sign == NTFS_RCRD_SIGNATURE) { info->initialized = true; break; @@ -1234,7 +1227,7 @@ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first, if (r_page->rhdr.sign != NTFS_FFFF_SIGNATURE) { /* * Remember if the signature does not - * indicate uninitialized file + * indicate uninitialized file. */ info->initialized = true; } @@ -1246,7 +1239,7 @@ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first, info->initialized = true; info->vbo = vbo; - /* Let's check the restart area if this is a valid page */ + /* Let's check the restart area if this is a valid page. */ if (!is_rst_page_hdr_valid(vbo, r_page)) goto check_result; ra = Add2Ptr(r_page, le16_to_cpu(r_page->ra_off)); @@ -1257,14 +1250,14 @@ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first, /* * We have a valid restart page header and restart area. * If chkdsk was run or we have no clients then we have - * no more checking to do + * no more checking to do. */ if (bchk || ra->client_idx[1] == LFS_NO_CLIENT_LE) { info->valid_page = true; goto check_result; } - /* Read the entire restart area */ + /* Read the entire restart area. */ sys_page_size = le32_to_cpu(r_page->sys_page_size); if (DefaultLogPageSize != sys_page_size) { kfree(r_page); @@ -1275,7 +1268,7 @@ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first, if (read_log_page(log, vbo, (struct RECORD_PAGE_HDR **)&r_page, &usa_error)) { - /* ignore any errors */ + /* Ignore any errors. */ kfree(r_page); r_page = NULL; continue; @@ -1288,7 +1281,10 @@ static int log_read_rst(struct ntfs_log *log, u32 l_size, bool first, } check_result: - /* If chkdsk was run then update the caller's values and return */ + /* + * If chkdsk was run then update the caller's + * values and return. + */ if (r_page->rhdr.sign == NTFS_CHKD_SIGNATURE) { info->chkdsk_was_run = true; info->last_lsn = le64_to_cpu(r_page->rhdr.lsn); @@ -1297,7 +1293,10 @@ check_result: return 0; } - /* If we have a valid page then copy the values we need from it */ + /* + * If we have a valid page then copy the values + * we need from it. + */ if (info->valid_page) { info->last_lsn = le64_to_cpu(ra->current_lsn); info->restart = true; @@ -1312,9 +1311,7 @@ check_result: } /* - * log_init_pg_hdr - * - * init "log' from restart page header + * Ilog_init_pg_hdr - Init @log from restart page header. */ static void log_init_pg_hdr(struct ntfs_log *log, u32 sys_page_size, u32 page_size, u16 major_ver, u16 minor_ver) @@ -1337,15 +1334,13 @@ static void log_init_pg_hdr(struct ntfs_log *log, u32 sys_page_size, } /* - * log_create - * - * init "log" in cases when we don't have a restart area to use + * log_create - Init @log in cases when we don't have a restart area to use. */ static void log_create(struct ntfs_log *log, u32 l_size, const u64 last_lsn, u32 open_log_count, bool wrapped, bool use_multi_page) { log->l_size = l_size; - /* All file offsets must be quadword aligned */ + /* All file offsets must be quadword aligned. */ log->file_data_bits = blksize_bits(l_size) - 3; log->seq_num_mask = (8 << log->file_data_bits) - 1; log->seq_num_bits = sizeof(u64) * 8 - log->file_data_bits; @@ -1357,21 +1352,21 @@ static void log_create(struct ntfs_log *log, u32 l_size, const u64 last_lsn, log->l_flags |= NTFSLOG_NO_LAST_LSN | NTFSLOG_NO_OLDEST_LSN; - /* Set the correct flags for the I/O and indicate if we have wrapped */ + /* Set the correct flags for the I/O and indicate if we have wrapped. */ if (wrapped) log->l_flags |= NTFSLOG_WRAPPED; if (use_multi_page) log->l_flags |= NTFSLOG_MULTIPLE_PAGE_IO; - /* Compute the log page values */ + /* Compute the log page values. */ log->data_off = ALIGN( offsetof(struct RECORD_PAGE_HDR, fixups) + sizeof(short) * ((log->page_size >> SECTOR_SHIFT) + 1), 8); log->data_size = log->page_size - log->data_off; log->record_header_len = sizeof(struct LFS_RECORD_HDR); - /* Remember the different page sizes for reservation */ + /* Remember the different page sizes for reservation. */ log->reserved = log->data_size - log->record_header_len; /* Compute the restart page values. */ @@ -1384,15 +1379,15 @@ static void log_create(struct ntfs_log *log, u32 l_size, const u64 last_lsn, /* * The total available log file space is the number of - * log file pages times the space available on each page + * log file pages times the space available on each page. */ log->total_avail_pages = log->l_size - log->first_page; log->total_avail = log->total_avail_pages >> log->page_bits; /* * We assume that we can't use the end of the page less than - * the file record size - * Then we won't need to reserve more than the caller asks for + * the file record size. + * Then we won't need to reserve more than the caller asks for. */ log->max_current_avail = log->total_avail * log->reserved; log->total_avail = log->total_avail * log->data_size; @@ -1400,9 +1395,7 @@ static void log_create(struct ntfs_log *log, u32 l_size, const u64 last_lsn, } /* - * log_create_ra - * - * This routine is called to fill a restart area from the values stored in 'log' + * log_create_ra - Fill a restart area from the values stored in @log. */ static struct RESTART_AREA *log_create_ra(struct ntfs_log *log) { @@ -1442,12 +1435,12 @@ static u32 final_log_off(struct ntfs_log *log, u64 lsn, u32 data_len) page_off -= 1; - /* Add the length of the header */ + /* Add the length of the header. */ data_len += log->record_header_len; /* - * If this lsn is contained this log page we are done - * Otherwise we need to walk through several log pages + * If this lsn is contained this log page we are done. + * Otherwise we need to walk through several log pages. */ if (data_len > tail) { data_len -= tail; @@ -1457,7 +1450,10 @@ static u32 final_log_off(struct ntfs_log *log, u64 lsn, u32 data_len) for (;;) { final_log_off = next_page_off(log, final_log_off); - /* We are done if the remaining bytes fit on this page */ + /* + * We are done if the remaining bytes + * fit on this page. + */ if (data_len <= tail) break; data_len -= tail; @@ -1466,7 +1462,7 @@ static u32 final_log_off(struct ntfs_log *log, u64 lsn, u32 data_len) /* * We add the remaining bytes to our starting position on this page - * and then add that value to the file offset of this log page + * and then add that value to the file offset of this log page. */ return final_log_off + data_len + page_off; } @@ -1483,11 +1479,11 @@ static int next_log_lsn(struct ntfs_log *log, const struct LFS_RECORD_HDR *rh, u64 seq = this_lsn >> log->file_data_bits; struct RECORD_PAGE_HDR *page = NULL; - /* Remember if we wrapped */ + /* Remember if we wrapped. */ if (end <= vbo) seq += 1; - /* log page header for this page */ + /* Log page header for this page. */ err = read_log_page(log, hdr_off, &page, NULL); if (err) return err; @@ -1495,11 +1491,11 @@ static int next_log_lsn(struct ntfs_log *log, const struct LFS_RECORD_HDR *rh, /* * If the lsn we were given was not the last lsn on this page, * then the starting offset for the next lsn is on a quad word - * boundary following the last file offset for the current lsn - * Otherwise the file offset is the start of the data on the next page + * boundary following the last file offset for the current lsn. + * Otherwise the file offset is the start of the data on the next page. */ if (this_lsn == le64_to_cpu(page->rhdr.lsn)) { - /* If we wrapped, we need to increment the sequence number */ + /* If we wrapped, we need to increment the sequence number. */ hdr_off = next_page_off(log, hdr_off); if (hdr_off == log->first_page) seq += 1; @@ -1509,12 +1505,12 @@ static int next_log_lsn(struct ntfs_log *log, const struct LFS_RECORD_HDR *rh, vbo = ALIGN(end, 8); } - /* Compute the lsn based on the file offset and the sequence count */ + /* Compute the lsn based on the file offset and the sequence count. */ *lsn = vbo_to_lsn(log, vbo, seq); /* - * If this lsn is within the legal range for the file, we return true - * Otherwise false indicates that there are no more lsn's + * If this lsn is within the legal range for the file, we return true. + * Otherwise false indicates that there are no more lsn's. */ if (!is_lsn_in_file(log, *lsn)) *lsn = 0; @@ -1525,32 +1521,30 @@ static int next_log_lsn(struct ntfs_log *log, const struct LFS_RECORD_HDR *rh, } /* - * current_log_avail - * - * calculate the number of bytes available for log records + * current_log_avail - Calculate the number of bytes available for log records. */ static u32 current_log_avail(struct ntfs_log *log) { u32 oldest_off, next_free_off, free_bytes; if (log->l_flags & NTFSLOG_NO_LAST_LSN) { - /* The entire file is available */ + /* The entire file is available. */ return log->max_current_avail; } /* * If there is a last lsn the restart area then we know that we will - * have to compute the free range - * If there is no oldest lsn then start at the first page of the file + * have to compute the free range. + * If there is no oldest lsn then start at the first page of the file. */ oldest_off = (log->l_flags & NTFSLOG_NO_OLDEST_LSN) ? log->first_page : (log->oldest_lsn_off & ~log->sys_page_mask); /* - * We will use the next log page offset to compute the next free page\ - * If we are going to reuse this page go to the next page - * If we are at the first page then use the end of the file + * We will use the next log page offset to compute the next free page. + * If we are going to reuse this page go to the next page. + * If we are at the first page then use the end of the file. */ next_free_off = (log->l_flags & NTFSLOG_REUSE_TAIL) ? log->next_page + log->page_size @@ -1558,12 +1552,12 @@ static u32 current_log_avail(struct ntfs_log *log) ? log->l_size : log->next_page; - /* If the two offsets are the same then there is no available space */ + /* If the two offsets are the same then there is no available space. */ if (oldest_off == next_free_off) return 0; /* * If the free offset follows the oldest offset then subtract - * this range from the total available pages + * this range from the total available pages. */ free_bytes = oldest_off < next_free_off @@ -1587,13 +1581,13 @@ static bool check_subseq_log_page(struct ntfs_log *log, /* * If the last lsn on the page occurs was written after the page - * that caused the original error then we have a fatal error + * that caused the original error then we have a fatal error. */ lsn_seq = lsn >> log->file_data_bits; /* * If the sequence number for the lsn the page is equal or greater - * than lsn we expect, then this is a subsequent write + * than lsn we expect, then this is a subsequent write. */ return lsn_seq >= seq || (lsn_seq == seq - 1 && log->first_page == vbo && @@ -1603,8 +1597,8 @@ static bool check_subseq_log_page(struct ntfs_log *log, /* * last_log_lsn * - * This routine walks through the log pages for a file, searching for the - * last log page written to the file + * Walks through the log pages for a file, searching for the + * last log page written to the file. */ static int last_log_lsn(struct ntfs_log *log) { @@ -1653,7 +1647,7 @@ static int last_log_lsn(struct ntfs_log *log) } next_tail: - /* Read second tail page (at pos 3/0x12000) */ + /* Read second tail page (at pos 3/0x12000). */ if (read_log_page(log, second_off, &second_tail, &usa_error) || usa_error || second_tail->rhdr.sign != NTFS_RCRD_SIGNATURE) { kfree(second_tail); @@ -1665,7 +1659,7 @@ next_tail: lsn2 = le64_to_cpu(second_tail->record_hdr.last_end_lsn); } - /* Read first tail page (at pos 2/0x2000 ) */ + /* Read first tail page (at pos 2/0x2000). */ if (read_log_page(log, final_off, &first_tail, &usa_error) || usa_error || first_tail->rhdr.sign != NTFS_RCRD_SIGNATURE) { kfree(first_tail); @@ -1811,10 +1805,10 @@ tail_read: next_page: tail_page = NULL; - /* Read the next log page */ + /* Read the next log page. */ err = read_log_page(log, curpage_off, &page, &usa_error); - /* Compute the next log page offset the file */ + /* Compute the next log page offset the file. */ nextpage_off = next_page_off(log, curpage_off); wrapped = nextpage_off == log->first_page; @@ -1893,14 +1887,14 @@ use_cur_page: /* * If we are at the expected first page of a transfer check to see - * if either tail copy is at this offset + * if either tail copy is at this offset. * If this page is the last page of a transfer, check if we wrote - * a subsequent tail copy + * a subsequent tail copy. */ if (page_cnt == page_pos || page_cnt == page_pos + 1) { /* * Check if the offset matches either the first or second - * tail copy. It is possible it will match both + * tail copy. It is possible it will match both. */ if (curpage_off == final_off) tail_page = first_tail; @@ -1922,32 +1916,35 @@ use_cur_page: use_tail_page: if (tail_page) { - /* we have a candidate for a tail copy */ + /* We have a candidate for a tail copy. */ lsn_cur = le64_to_cpu(tail_page->record_hdr.last_end_lsn); if (last_ok_lsn < lsn_cur) { /* * If the sequence number is not expected, - * then don't use the tail copy + * then don't use the tail copy. */ if (expected_seq != (lsn_cur >> log->file_data_bits)) tail_page = NULL; } else if (last_ok_lsn > lsn_cur) { /* * If the last lsn is greater than the one on - * this page then forget this tail + * this page then forget this tail. */ tail_page = NULL; } } - /* If we have an error on the current page, we will break of this loop */ + /* + *If we have an error on the current page, + * we will break of this loop. + */ if (err || usa_error) goto check_tail; /* * Done if the last lsn on this page doesn't match the previous known - * last lsn or the sequence number is not expected + * last lsn or the sequence number is not expected. */ lsn_cur = le64_to_cpu(page->rhdr.lsn); if (last_ok_lsn != lsn_cur && @@ -1956,9 +1953,9 @@ use_tail_page: } /* - * Check that the page position and page count values are correct + * Check that the page position and page count values are correct. * If this is the first page of a transfer the position must be 1 - * and the count will be unknown + * and the count will be unknown. */ if (page_cnt == page_pos) { if (page->page_pos != cpu_to_le16(1) && @@ -1975,20 +1972,20 @@ use_tail_page: le16_to_cpu(page->page_pos) != page_pos + 1) { /* * The page position better be 1 more than the last page - * position and the page count better match + * position and the page count better match. */ goto check_tail; } /* * We have a valid page the file and may have a valid page - * the tail copy area + * the tail copy area. * If the tail page was written after the page the file then - * break of the loop + * break of the loop. */ if (tail_page && le64_to_cpu(tail_page->record_hdr.last_end_lsn) > lsn_cur) { - /* Remember if we will replace the page */ + /* Remember if we will replace the page. */ replace_page = true; goto check_tail; } @@ -1998,7 +1995,7 @@ use_tail_page: if (is_log_record_end(page)) { /* * Since we have read this page we know the sequence number - * is the same as our expected value + * is the same as our expected value. */ log->seq_num = expected_seq; log->last_lsn = le64_to_cpu(page->record_hdr.last_end_lsn); @@ -2007,7 +2004,7 @@ use_tail_page: /* * If there is room on this page for another header then - * remember we want to reuse the page + * remember we want to reuse the page. */ if (log->record_header_len <= log->page_size - @@ -2019,14 +2016,14 @@ use_tail_page: log->next_page = nextpage_off; } - /* Remember if we wrapped the log file */ + /* Remember if we wrapped the log file. */ if (wrapped_file) log->l_flags |= NTFSLOG_WRAPPED; } /* * Remember the last page count and position. - * Also remember the last known lsn + * Also remember the last known lsn. */ page_cnt = le16_to_cpu(page->page_count); page_pos = le16_to_cpu(page->page_pos); @@ -2067,19 +2064,19 @@ check_tail: log->l_flags |= NTFSLOG_WRAPPED; } - /* Remember that the partial IO will start at the next page */ + /* Remember that the partial IO will start at the next page. */ second_off = nextpage_off; /* * If the next page is the first page of the file then update - * the sequence number for log records which begon the next page + * the sequence number for log records which begon the next page. */ if (wrapped) expected_seq += 1; /* * If we have a tail copy or are performing single page I/O we can - * immediately look at the next page + * immediately look at the next page. */ if (replace_page || (log->ra->flags & RESTART_SINGLE_PAGE_IO)) { page_cnt = 2; @@ -2105,19 +2102,19 @@ next_test_page: kfree(tst_page); tst_page = NULL; - /* Walk through the file, reading log pages */ + /* Walk through the file, reading log pages. */ err = read_log_page(log, nextpage_off, &tst_page, &usa_error); /* * If we get a USA error then assume that we correctly found - * the end of the original transfer + * the end of the original transfer. */ if (usa_error) goto file_is_valid; /* * If we were able to read the page, we examine it to see if it - * is the same or different Io block + * is the same or different Io block. */ if (err) goto next_test_page_1; @@ -2148,7 +2145,7 @@ next_test_page_1: goto next_test_page; check_valid: - /* Skip over the remaining pages this transfer */ + /* Skip over the remaining pages this transfer. */ remain_pages = page_cnt - page_pos - 1; part_io_count += remain_pages; @@ -2160,7 +2157,7 @@ check_valid: expected_seq += 1; } - /* Call our routine to check this log page */ + /* Call our routine to check this log page. */ kfree(tst_page); tst_page = NULL; @@ -2173,7 +2170,7 @@ check_valid: file_is_valid: - /* We have a valid file */ + /* We have a valid file. */ if (page_off1 || tail_page) { struct RECORD_PAGE_HDR *tmp_page; @@ -2203,11 +2200,11 @@ file_is_valid: /* * Correct page and copy the data from this page - * into it and flush it to disk + * into it and flush it to disk. */ memcpy(page, tmp_page, log->page_size); - /* Fill last flushed lsn value flush the page */ + /* Fill last flushed lsn value flush the page. */ if (log->major_ver < 2) page->rhdr.lsn = page->record_hdr.last_end_lsn; else @@ -2251,10 +2248,9 @@ out: } /* - * read_log_rec_buf + * read_log_rec_buf - Copy a log record from the file to a buffer. * - * copies a log record from the file to a buffer - * The log record may span several log pages and may even wrap the file + * The log record may span several log pages and may even wrap the file. */ static int read_log_rec_buf(struct ntfs_log *log, const struct LFS_RECORD_HDR *rh, void *buffer) @@ -2268,7 +2264,7 @@ static int read_log_rec_buf(struct ntfs_log *log, /* * While there are more bytes to transfer, - * we continue to attempt to perform the read + * we continue to attempt to perform the read. */ for (;;) { bool usa_error; @@ -2285,7 +2281,7 @@ static int read_log_rec_buf(struct ntfs_log *log, /* * The last lsn on this page better be greater or equal - * to the lsn we are copying + * to the lsn we are copying. */ if (lsn > le64_to_cpu(ph->rhdr.lsn)) { err = -EINVAL; @@ -2294,7 +2290,7 @@ static int read_log_rec_buf(struct ntfs_log *log, memcpy(buffer, Add2Ptr(ph, off), tail); - /* If there are no more bytes to transfer, we exit the loop */ + /* If there are no more bytes to transfer, we exit the loop. */ if (!data_len) { if (!is_log_record_end(ph) || lsn > le64_to_cpu(ph->record_hdr.last_end_lsn)) { @@ -2314,8 +2310,8 @@ static int read_log_rec_buf(struct ntfs_log *log, off = log->data_off; /* - * adjust our pointer the user's buffer to transfer - * the next block to + * Adjust our pointer the user's buffer to transfer + * the next block to. */ buffer = Add2Ptr(buffer, tail); } @@ -2339,7 +2335,7 @@ static int read_rst_area(struct ntfs_log *log, struct NTFS_RESTART **rst_, *lsn = 0; *rst_ = NULL; - /* If the client doesn't have a restart area, go ahead and exit now */ + /* If the client doesn't have a restart area, go ahead and exit now. */ if (!lsnc) return 0; @@ -2352,7 +2348,7 @@ static int read_rst_area(struct ntfs_log *log, struct NTFS_RESTART **rst_, lsnr = le64_to_cpu(rh->this_lsn); if (lsnc != lsnr) { - /* If the lsn values don't match, then the disk is corrupt */ + /* If the lsn values don't match, then the disk is corrupt. */ err = -EINVAL; goto out; } @@ -2376,7 +2372,7 @@ static int read_rst_area(struct ntfs_log *log, struct NTFS_RESTART **rst_, goto out; } - /* Copy the data into the 'rst' buffer */ + /* Copy the data into the 'rst' buffer. */ err = read_log_rec_buf(log, rh, rst); if (err) goto out; @@ -2397,7 +2393,7 @@ static int find_log_rec(struct ntfs_log *log, u64 lsn, struct lcb *lcb) struct LFS_RECORD_HDR *rh = lcb->lrh; u32 rec_len, len; - /* Read the record header for this lsn */ + /* Read the record header for this lsn. */ if (!rh) { err = read_log_page(log, lsn_to_vbo(log, lsn), (struct RECORD_PAGE_HDR **)&rh, NULL); @@ -2409,7 +2405,7 @@ static int find_log_rec(struct ntfs_log *log, u64 lsn, struct lcb *lcb) /* * If the lsn the log record doesn't match the desired - * lsn then the disk is corrupt + * lsn then the disk is corrupt. */ if (lsn != le64_to_cpu(rh->this_lsn)) return -EINVAL; @@ -2417,8 +2413,8 @@ static int find_log_rec(struct ntfs_log *log, u64 lsn, struct lcb *lcb) len = le32_to_cpu(rh->client_data_len); /* - * check that the length field isn't greater than the total - * available space the log file + * Check that the length field isn't greater than the total + * available space the log file. */ rec_len = len + log->record_header_len; if (rec_len >= log->total_avail) @@ -2426,7 +2422,7 @@ static int find_log_rec(struct ntfs_log *log, u64 lsn, struct lcb *lcb) /* * If the entire log record is on this log page, - * put a pointer to the log record the context block + * put a pointer to the log record the context block. */ if (rh->flags & LOG_RECORD_MULTI_PAGE) { void *lr = kmalloc(len, GFP_NOFS); @@ -2437,12 +2433,12 @@ static int find_log_rec(struct ntfs_log *log, u64 lsn, struct lcb *lcb) lcb->log_rec = lr; lcb->alloc = true; - /* Copy the data into the buffer returned */ + /* Copy the data into the buffer returned. */ err = read_log_rec_buf(log, rh, lr); if (err) return err; } else { - /* If beyond the end of the current page -> an error */ + /* If beyond the end of the current page -> an error. */ u32 page_off = lsn_to_page_off(log, lsn); if (page_off + len + log->record_header_len > log->page_size) @@ -2456,9 +2452,7 @@ static int find_log_rec(struct ntfs_log *log, u64 lsn, struct lcb *lcb) } /* - * read_log_rec_lcb - * - * initiates the query operation. + * read_log_rec_lcb - Init the query operation. */ static int read_log_rec_lcb(struct ntfs_log *log, u64 lsn, u32 ctx_mode, struct lcb **lcb_) @@ -2476,7 +2470,7 @@ static int read_log_rec_lcb(struct ntfs_log *log, u64 lsn, u32 ctx_mode, return -EINVAL; } - /* check that the given lsn is the legal range for this client */ + /* Check that the given lsn is the legal range for this client. */ cr = Add2Ptr(log->ra, le16_to_cpu(log->ra->client_off)); if (!verify_client_lsn(log, cr, lsn)) @@ -2488,7 +2482,7 @@ static int read_log_rec_lcb(struct ntfs_log *log, u64 lsn, u32 ctx_mode, lcb->client = log->client_id; lcb->ctx_mode = ctx_mode; - /* Find the log record indicated by the given lsn */ + /* Find the log record indicated by the given lsn. */ err = find_log_rec(log, lsn, lcb); if (err) goto out; @@ -2505,7 +2499,7 @@ out: /* * find_client_next_lsn * - * attempt to find the next lsn to return to a client based on the context mode. + * Attempt to find the next lsn to return to a client based on the context mode. */ static int find_client_next_lsn(struct ntfs_log *log, struct lcb *lcb, u64 *lsn) { @@ -2519,7 +2513,7 @@ static int find_client_next_lsn(struct ntfs_log *log, struct lcb *lcb, u64 *lsn) if (lcb_ctx_next != lcb->ctx_mode) goto check_undo_next; - /* Loop as long as another lsn can be found */ + /* Loop as long as another lsn can be found. */ for (;;) { u64 current_lsn; @@ -2705,7 +2699,7 @@ static inline bool check_attr(const struct MFT_REC *rec, u64 dsize, svcn, evcn; u16 run_off; - /* Check the fixed part of the attribute record header */ + /* Check the fixed part of the attribute record header. */ if (asize >= sbi->record_size || asize + PtrOffset(rec, attr) >= sbi->record_size || (attr->name_len && @@ -2714,7 +2708,7 @@ static inline bool check_attr(const struct MFT_REC *rec, return false; } - /* Check the attribute fields */ + /* Check the attribute fields. */ switch (attr->non_res) { case 0: rsize = le32_to_cpu(attr->res.data_size); @@ -2797,7 +2791,7 @@ static inline bool check_file_record(const struct MFT_REC *rec, u16 ao = le16_to_cpu(rec->attr_off); u32 rs = sbi->record_size; - /* check the file record header for consistency */ + /* Check the file record header for consistency. */ if (rec->rhdr.sign != NTFS_FILE_SIGNATURE || fo > (SECTOR_SIZE - ((rs >> SECTOR_SHIFT) + 1) * sizeof(short)) || (fn - 1) * SECTOR_SIZE != rs || ao < MFTRECORD_FIXUP_OFFSET_1 || @@ -2806,7 +2800,7 @@ static inline bool check_file_record(const struct MFT_REC *rec, return false; } - /* Loop to check all of the attributes */ + /* Loop to check all of the attributes. */ for (attr = Add2Ptr(rec, ao); attr->type != ATTR_END; attr = Add2Ptr(attr, le32_to_cpu(attr->size))) { if (check_attr(rec, attr, sbi)) @@ -2959,7 +2953,11 @@ struct OpenAttr { // CLST rno; }; -/* Returns 0 if 'attr' has the same type and name */ +/* + * cmp_type_and_name + * + * Return: 0 if 'attr' has the same type and name. + */ static inline int cmp_type_and_name(const struct ATTRIB *a1, const struct ATTRIB *a2) { @@ -3032,10 +3030,8 @@ static struct ATTRIB *attr_create_nonres_log(struct ntfs_sb_info *sbi, } /* - * do_action - * - * common routine for the Redo and Undo Passes - * If rlsn is NULL then undo + * do_action - Common routine for the Redo and Undo Passes. + * @rlsn: If it is NULL then undo. */ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe, const struct LOG_REC_HDR *lrh, u32 op, void *data, @@ -3072,10 +3068,10 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe, oa = oe->ptr; - /* Big switch to prepare */ + /* Big switch to prepare. */ switch (op) { /* ============================================================ - * Process MFT records, as described by the current log record + * Process MFT records, as described by the current log record. * ============================================================ */ case InitializeFileRecordSegment: @@ -3104,7 +3100,7 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe, if (err) goto out; } else { - /* read from disk */ + /* Read from disk. */ err = mi_get(sbi, rno, &mi); if (err) return err; @@ -3161,9 +3157,8 @@ skip_load_parent: inode_parent = NULL; break; - /* ============================================================ - * Process attributes, as described by the current log record - * ============================================================ + /* + * Process attributes, as described by the current log record. */ case UpdateNonresidentValue: case AddIndexEntryAllocation: @@ -3208,7 +3203,7 @@ skip_load_parent: WARN_ON(1); } - /* Big switch to do operation */ + /* Big switch to do operation. */ switch (op) { case InitializeFileRecordSegment: if (roff + dlen > record_size) @@ -3311,7 +3306,7 @@ skip_load_parent: if (nsize < asize) { memmove(Add2Ptr(attr, aoff), data, dlen); - data = NULL; // To skip below memmove + data = NULL; // To skip below memmove(). } memmove(Add2Ptr(attr, nsize), Add2Ptr(attr, asize), @@ -3734,11 +3729,11 @@ dirty_vol: } /* - * log_replay + * log_replay - Replays log and empties it. * - * this function is called during mount operation - * it replays log and empties it - * initialized is set false if logfile contains '-1' + * This function is called during mount operation. + * It replays log and empties it. + * Initialized is set false if logfile contains '-1'. */ int log_replay(struct ntfs_inode *ni, bool *initialized) { @@ -3784,7 +3779,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized) u16 t16; u32 t32; - /* Get the size of page. NOTE: To replay we can use default page */ + /* Get the size of page. NOTE: To replay we can use default page. */ #if PAGE_SIZE >= DefaultLogPageSize && PAGE_SIZE <= DefaultLogPageSize * 2 page_size = norm_file_page(PAGE_SIZE, &l_size, true); #else @@ -3810,7 +3805,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized) log->page_mask = page_size - 1; log->page_bits = blksize_bits(page_size); - /* Look for a restart area on the disk */ + /* Look for a restart area on the disk. */ err = log_read_rst(log, l_size, true, &rst_info); if (err) goto out; @@ -3820,7 +3815,7 @@ int log_replay(struct ntfs_inode *ni, bool *initialized) if (!rst_info.restart) { if (rst_info.initialized) { - /* no restart area but the file is not initialized */ + /* No restart area but the file is not initialized. */ err = -EINVAL; goto out; } @@ -3843,14 +3838,14 @@ int log_replay(struct ntfs_inode *ni, bool *initialized) /* * If the restart offset above wasn't zero then we won't - * look for a second restart + * look for a second restart. */ if (rst_info.vbo) goto check_restart_area; err = log_read_rst(log, l_size, false, &rst_info2); - /* Determine which restart area to use */ + /* Determine which restart area to use. */ if (!rst_info2.restart || rst_info2.last_lsn <= rst_info.last_lsn) goto use_first_page; @@ -3877,10 +3872,13 @@ use_first_page: kfree(rst_info2.r_page); check_restart_area: - /* If the restart area is at offset 0, we want to write the second restart area first */ + /* + * If the restart area is at offset 0, we want + * to write the second restart area first. + */ log->init_ra = !!rst_info.vbo; - /* If we have a valid page then grab a pointer to the restart area */ + /* If we have a valid page then grab a pointer to the restart area. */ ra2 = rst_info.valid_page ? Add2Ptr(rst_info.r_page, le16_to_cpu(rst_info.r_page->ra_off)) @@ -3892,7 +3890,7 @@ check_restart_area: bool use_multi_page = false; u32 open_log_count; - /* Do some checks based on whether we have a valid log page */ + /* Do some checks based on whether we have a valid log page. */ if (!rst_info.valid_page) { open_log_count = get_random_int(); goto init_log_instance; @@ -3901,7 +3899,7 @@ check_restart_area: /* * If the restart page size isn't changing then we want to - * check how much work we need to do + * check how much work we need to do. */ if (page_size != le32_to_cpu(rst_info.r_page->sys_page_size)) goto init_log_instance; @@ -3919,7 +3917,9 @@ init_log_instance: } log->ra = ra; - /* Put the restart areas and initialize the log file as required */ + /* Put the restart areas and initialize + * the log file as required. + */ goto process_log; } @@ -3929,9 +3929,9 @@ init_log_instance: } /* - * If the log page or the system page sizes have changed, we can't use the log file - * We must use the system page size instead of the default size - * if there is not a clean shutdown + * If the log page or the system page sizes have changed, we can't + * use the log file. We must use the system page size instead of the + * default size if there is not a clean shutdown. */ t32 = le32_to_cpu(rst_info.r_page->sys_page_size); if (page_size != t32) { @@ -3946,7 +3946,7 @@ init_log_instance: goto out; } - /* If the file size has shrunk then we won't mount it */ + /* If the file size has shrunk then we won't mount it. */ if (l_size < le64_to_cpu(ra2->l_size)) { err = -EINVAL; goto out; @@ -3973,27 +3973,30 @@ init_log_instance: vbo = lsn_to_vbo(log, log->last_lsn); if (vbo < log->first_page) { - /* This is a pseudo lsn */ + /* This is a pseudo lsn. */ log->l_flags |= NTFSLOG_NO_LAST_LSN; log->next_page = log->first_page; goto find_oldest; } - /* Find the end of this log record */ + /* Find the end of this log record. */ off = final_log_off(log, log->last_lsn, le32_to_cpu(ra2->last_lsn_data_len)); - /* If we wrapped the file then increment the sequence number */ + /* If we wrapped the file then increment the sequence number. */ if (off <= vbo) { log->seq_num += 1; log->l_flags |= NTFSLOG_WRAPPED; } - /* Now compute the next log page to use */ + /* Now compute the next log page to use. */ vbo &= ~log->sys_page_mask; tail = log->page_size - (off & log->page_mask) - 1; - /* If we can fit another log record on the page, move back a page the log file */ + /* + *If we can fit another log record on the page, + * move back a page the log file. + */ if (tail >= log->record_header_len) { log->l_flags |= NTFSLOG_REUSE_TAIL; log->next_page = vbo; @@ -4002,7 +4005,10 @@ init_log_instance: } find_oldest: - /* Find the oldest client lsn. Use the last flushed lsn as a starting point */ + /* + * Find the oldest client lsn. Use the last + * flushed lsn as a starting point. + */ log->oldest_lsn = log->last_lsn; oldest_client_lsn(Add2Ptr(ra2, le16_to_cpu(ra2->client_off)), ra2->client_idx[1], &log->oldest_lsn); @@ -4048,18 +4054,18 @@ find_oldest: le32_add_cpu(&ra->open_log_count, 1); - /* Now we need to walk through looking for the last lsn */ + /* Now we need to walk through looking for the last lsn. */ err = last_log_lsn(log); if (err) goto out; log->current_avail = current_log_avail(log); - /* Remember which restart area to write first */ + /* Remember which restart area to write first. */ log->init_ra = rst_info.vbo; process_log: - /* 1.0, 1.1, 2.0 log->major_ver/minor_ver - short values */ + /* 1.0, 1.1, 2.0 log->major_ver/minor_ver - short values. */ switch ((log->major_ver << 16) + log->minor_ver) { case 0x10000: case 0x10001: @@ -4073,12 +4079,12 @@ process_log: goto out; } - /* One client "NTFS" per logfile */ + /* One client "NTFS" per logfile. */ ca = Add2Ptr(ra, le16_to_cpu(ra->client_off)); for (client = ra->client_idx[1];; client = cr->next_client) { if (client == LFS_NO_CLIENT_LE) { - /* Insert "NTFS" client LogFile */ + /* Insert "NTFS" client LogFile. */ client = ra->client_idx[0]; if (client == LFS_NO_CLIENT_LE) return -EINVAL; @@ -4110,7 +4116,7 @@ process_log: break; } - /* Update the client handle with the client block information */ + /* Update the client handle with the client block information. */ log->client_id.seq_num = cr->seq_num; log->client_id.client_idx = client; @@ -4127,7 +4133,7 @@ process_log: if (!checkpt_lsn) checkpt_lsn = ra_lsn; - /* Allocate and Read the Transaction Table */ + /* Allocate and Read the Transaction Table. */ if (!rst->transact_table_len) goto check_dirty_page_table; @@ -4151,7 +4157,7 @@ process_log: rt = Add2Ptr(lrh, t16); t32 = rec_len - t16; - /* Now check that this is a valid restart table */ + /* Now check that this is a valid restart table. */ if (!check_rstbl(rt, t32)) { err = -EINVAL; goto out; @@ -4167,7 +4173,7 @@ process_log: lcb = NULL; check_dirty_page_table: - /* The next record back should be the Dirty Pages Table */ + /* The next record back should be the Dirty Pages Table. */ if (!rst->dirty_pages_len) goto check_attribute_names; @@ -4191,7 +4197,7 @@ check_dirty_page_table: rt = Add2Ptr(lrh, t16); t32 = rec_len - t16; - /* Now check that this is a valid restart table */ + /* Now check that this is a valid restart table. */ if (!check_rstbl(rt, t32)) { err = -EINVAL; goto out; @@ -4203,14 +4209,14 @@ check_dirty_page_table: goto out; } - /* Convert Ra version '0' into version '1' */ + /* Convert Ra version '0' into version '1'. */ if (rst->major_ver) goto end_conv_1; dp = NULL; while ((dp = enum_rstbl(dptbl, dp))) { struct DIR_PAGE_ENTRY_32 *dp0 = (struct DIR_PAGE_ENTRY_32 *)dp; - // NOTE: Danger. Check for of boundary + // NOTE: Danger. Check for of boundary. memmove(&dp->vcn, &dp0->vcn_low, 2 * sizeof(u64) + le32_to_cpu(dp->lcns_follow) * sizeof(u64)); @@ -4220,7 +4226,10 @@ end_conv_1: lcb_put(lcb); lcb = NULL; - /* Go through the table and remove the duplicates, remembering the oldest lsn values */ + /* + * Go through the table and remove the duplicates, + * remembering the oldest lsn values. + */ if (sbi->cluster_size <= log->page_size) goto trace_dp_table; @@ -4242,7 +4251,7 @@ end_conv_1: } trace_dp_table: check_attribute_names: - /* The next record should be the Attribute Names */ + /* The next record should be the Attribute Names. */ if (!rst->attr_names_len) goto check_attr_table; @@ -4270,7 +4279,7 @@ check_attribute_names: lcb = NULL; check_attr_table: - /* The next record should be the attribute Table */ + /* The next record should be the attribute Table. */ if (!rst->open_attr_len) goto check_attribute_names2; @@ -4307,13 +4316,13 @@ check_attr_table: log->open_attr_tbl = oatbl; - /* Clear all of the Attr pointers */ + /* Clear all of the Attr pointers. */ oe = NULL; while ((oe = enum_rstbl(oatbl, oe))) { if (!rst->major_ver) { struct OPEN_ATTR_ENRTY_32 oe0; - /* Really 'oe' points to OPEN_ATTR_ENRTY_32 */ + /* Really 'oe' points to OPEN_ATTR_ENRTY_32. */ memcpy(&oe0, oe, SIZEOF_OPENATTRIBUTEENTRY0); oe->bytes_per_index = oe0.bytes_per_index; @@ -4351,7 +4360,7 @@ check_attribute_names2: trace_attribute_table: /* * If the checkpt_lsn is zero, then this is a freshly - * formatted disk and we have no work to do + * formatted disk and we have no work to do. */ if (!checkpt_lsn) { err = 0; @@ -4371,12 +4380,12 @@ trace_attribute_table: /* Start the analysis pass from the Checkpoint lsn. */ rec_lsn = checkpt_lsn; - /* Read the first lsn */ + /* Read the first lsn. */ err = read_log_rec_lcb(log, checkpt_lsn, lcb_ctx_next, &lcb); if (err) goto out; - /* Loop to read all subsequent records to the end of the log file */ + /* Loop to read all subsequent records to the end of the log file. */ next_log_record_analyze: err = read_next_log_rec(log, lcb, &rec_lsn); if (err) @@ -4397,7 +4406,7 @@ next_log_record_analyze: /* * The first lsn after the previous lsn remembered - * the checkpoint is the first candidate for the rlsn + * the checkpoint is the first candidate for the rlsn. */ if (!rlsn) rlsn = rec_lsn; @@ -4406,8 +4415,8 @@ next_log_record_analyze: goto next_log_record_analyze; /* - * Now update the Transaction Table for this transaction - * If there is no entry present or it is unallocated we allocate the entry + * Now update the Transaction Table for this transaction. If there + * is no entry present or it is unallocated we allocate the entry. */ if (!trtbl) { trtbl = init_rsttbl(sizeof(struct TRANSACTION_ENTRY), @@ -4435,12 +4444,12 @@ next_log_record_analyze: /* * If this is a compensation log record, then change - * the undo_next_lsn to be the undo_next_lsn of this record + * the undo_next_lsn to be the undo_next_lsn of this record. */ if (lrh->undo_op == cpu_to_le16(CompensationLogRecord)) tr->undo_next_lsn = frh->client_undo_next_lsn; - /* Dispatch to handle log record depending on type */ + /* Dispatch to handle log record depending on type. */ switch (le16_to_cpu(lrh->redo_op)) { case InitializeFileRecordSegment: case DeallocateFileRecordSegment: @@ -4474,7 +4483,7 @@ next_log_record_analyze: /* * Calculate the number of clusters per page the system - * which wrote the checkpoint, possibly creating the table + * which wrote the checkpoint, possibly creating the table. */ if (dptbl) { t32 = (le16_to_cpu(dptbl->size) - @@ -4504,9 +4513,9 @@ next_log_record_analyze: copy_lcns: /* - * Copy the Lcns from the log record into the Dirty Page Entry - * TODO: for different page size support, must somehow make - * whole routine a loop, case Lcns do not fit below + * Copy the Lcns from the log record into the Dirty Page Entry. + * TODO: For different page size support, must somehow make + * whole routine a loop, case Lcns do not fit below. */ t16 = le16_to_cpu(lrh->lcns_follow); for (i = 0; i < t16; i++) { @@ -4523,7 +4532,7 @@ copy_lcns: const struct LCN_RANGE *r = Add2Ptr(lrh, le16_to_cpu(lrh->redo_off)); - /* Loop through all of the Lcn ranges this log record */ + /* Loop through all of the Lcn ranges this log record. */ for (i = 0; i < range_count; i++, r++) { u64 lcn0 = le64_to_cpu(r->lcn); u64 lcn_e = lcn0 + le64_to_cpu(r->len) - 1; @@ -4549,7 +4558,7 @@ copy_lcns: if (t16 >= bytes_per_rt(oatbl)) { /* * Compute how big the table needs to be. - * Add 10 extra entries for some cushion + * Add 10 extra entries for some cushion. */ u32 new_e = t16 / le16_to_cpu(oatbl->size); @@ -4563,7 +4572,7 @@ copy_lcns: } } - /* Point to the entry being opened */ + /* Point to the entry being opened. */ oe = alloc_rsttbl_from_idx(&oatbl, t16); log->open_attr_tbl = oatbl; if (!oe) { @@ -4571,10 +4580,10 @@ copy_lcns: goto out; } - /* Initialize this entry from the log record */ + /* Initialize this entry from the log record. */ t16 = le16_to_cpu(lrh->redo_off); if (!rst->major_ver) { - /* Convert version '0' into version '1' */ + /* Convert version '0' into version '1'. */ struct OPEN_ATTR_ENRTY_32 *oe0 = Add2Ptr(lrh, t16); oe->bytes_per_index = oe0->bytes_per_index; @@ -4642,13 +4651,13 @@ copy_lcns: case AttributeNamesDump: case DirtyPageTableDump: case TransactionTableDump: - /* The following cases require no action the Analysis Pass */ + /* The following cases require no action the Analysis Pass. */ goto next_log_record_analyze; default: /* * All codes will be explicitly handled. - * If we see a code we do not expect, then we are trouble + * If we see a code we do not expect, then we are trouble. */ goto next_log_record_analyze; } @@ -4659,7 +4668,7 @@ end_log_records_enumerate: /* * Scan the Dirty Page Table and Transaction Table for - * the lowest lsn, and return it as the Redo lsn + * the lowest lsn, and return it as the Redo lsn. */ dp = NULL; while ((dp = enum_rstbl(dptbl, dp))) { @@ -4675,7 +4684,10 @@ end_log_records_enumerate: rlsn = t64; } - /* Only proceed if the Dirty Page Table or Transaction table are not empty */ + /* + * Only proceed if the Dirty Page Table or Transaction + * table are not empty. + */ if ((!dptbl || !dptbl->total) && (!trtbl || !trtbl->total)) goto end_reply; @@ -4683,7 +4695,7 @@ end_log_records_enumerate: if (is_ro) goto out; - /* Reopen all of the attributes with dirty pages */ + /* Reopen all of the attributes with dirty pages. */ oe = NULL; next_open_attribute: @@ -4779,8 +4791,8 @@ final_oe: goto next_open_attribute; /* - * Now loop through the dirty page table to extract all of the Vcn/Lcn - * Mapping that we have, and insert it into the appropriate run + * Now loop through the dirty page table to extract all of the Vcn/Lcn. + * Mapping that we have, and insert it into the appropriate run. */ next_dirty_page: dp = enum_rstbl(dptbl, dp); @@ -4834,8 +4846,8 @@ next_dirty_page_vcn: do_redo_1: /* * Perform the Redo Pass, to restore all of the dirty pages to the same - * contents that they had immediately before the crash - * If the dirty page table is empty, then we can skip the entire Redo Pass + * contents that they had immediately before the crash. If the dirty + * page table is empty, then we can skip the entire Redo Pass. */ if (!dptbl || !dptbl->total) goto do_undo_action; @@ -4844,15 +4856,15 @@ do_redo_1: /* * Read the record at the Redo lsn, before falling - * into common code to handle each record + * into common code to handle each record. */ err = read_log_rec_lcb(log, rlsn, lcb_ctx_next, &lcb); if (err) goto out; /* - * Now loop to read all of our log records forwards, - * until we hit the end of the file, cleaning up at the end + * Now loop to read all of our log records forwards, until + * we hit the end of the file, cleaning up at the end. */ do_action_next: frh = lcb->lrh; @@ -4869,7 +4881,7 @@ do_action_next: goto out; } - /* Ignore log records that do not update pages */ + /* Ignore log records that do not update pages. */ if (lrh->lcns_follow) goto find_dirty_page; @@ -4914,11 +4926,11 @@ find_dirty_page: goto read_next_log_do_action; } - /* Point to the Redo data and get its length */ + /* Point to the Redo data and get its length. */ data = Add2Ptr(lrh, le16_to_cpu(lrh->redo_off)); dlen = le16_to_cpu(lrh->redo_len); - /* Shorten length by any Lcns which were deleted */ + /* Shorten length by any Lcns which were deleted. */ saved_len = dlen; for (i = le16_to_cpu(lrh->lcns_follow); i; i--) { @@ -4929,7 +4941,7 @@ find_dirty_page: le16_to_cpu(lrh->attr_off); voff += le16_to_cpu(lrh->cluster_off) << SECTOR_SHIFT; - /* If the Vcn question is allocated, we can just get out.*/ + /* If the Vcn question is allocated, we can just get out. */ j = le64_to_cpu(lrh->target_vcn) - le64_to_cpu(dp->vcn); if (dp->page_lcns[j + i - 1]) break; @@ -4939,13 +4951,13 @@ find_dirty_page: /* * Calculate the allocated space left relative to the - * log record Vcn, after removing this unallocated Vcn + * log record Vcn, after removing this unallocated Vcn. */ alen = (i - 1) << sbi->cluster_bits; /* * If the update described this log record goes beyond - * the allocated space, then we will have to reduce the length + * the allocated space, then we will have to reduce the length. */ if (voff >= alen) dlen = 0; @@ -4953,7 +4965,10 @@ find_dirty_page: dlen = alen - voff; } - /* If the resulting dlen from above is now zero, we can skip this log record */ + /* + * If the resulting dlen from above is now zero, + * we can skip this log record. + */ if (!dlen && saved_len) goto read_next_log_do_action; @@ -4961,12 +4976,12 @@ find_dirty_page: if (can_skip_action(t16)) goto read_next_log_do_action; - /* Apply the Redo operation a common routine */ + /* Apply the Redo operation a common routine. */ err = do_action(log, oe, lrh, t16, data, dlen, rec_len, &rec_lsn); if (err) goto out; - /* Keep reading and looping back until end of file */ + /* Keep reading and looping back until end of file. */ read_next_log_do_action: err = read_next_log_rec(log, lcb, &rec_lsn); if (!err && rec_lsn) @@ -4976,7 +4991,7 @@ read_next_log_do_action: lcb = NULL; do_undo_action: - /* Scan Transaction Table */ + /* Scan Transaction Table. */ tr = NULL; transaction_table_next: tr = enum_rstbl(trtbl, tr); @@ -4993,19 +5008,19 @@ transaction_table_next: /* * We only have to do anything if the transaction has - * something its undo_next_lsn field + * something its undo_next_lsn field. */ if (!undo_next_lsn) goto commit_undo; - /* Read the first record to be undone by this transaction */ + /* Read the first record to be undone by this transaction. */ err = read_log_rec_lcb(log, undo_next_lsn, lcb_ctx_undo_next, &lcb); if (err) goto out; /* * Now loop to read all of our log records forwards, - * until we hit the end of the file, cleaning up at the end + * until we hit the end of the file, cleaning up at the end. */ undo_action_next: @@ -5035,7 +5050,7 @@ undo_action_next: /* * If the mapping isn't already the table or the mapping * corresponds to a hole the mapping, we need to make sure - * there is no partial page already memory + * there is no partial page already memory. */ if (is_mapped && lcn != SPARSE_LCN && clen >= t16) goto add_allocated_vcns; @@ -5063,17 +5078,17 @@ add_allocated_vcns: if (can_skip_action(t16)) goto read_next_log_undo_action; - /* Point to the Redo data and get its length */ + /* Point to the Redo data and get its length. */ data = Add2Ptr(lrh, le16_to_cpu(lrh->undo_off)); dlen = le16_to_cpu(lrh->undo_len); - /* it is time to apply the undo action */ + /* It is time to apply the undo action. */ err = do_action(log, oe, lrh, t16, data, dlen, rec_len, NULL); read_next_log_undo_action: /* * Keep reading and looping back until we have read the - * last record for this transaction + * last record for this transaction. */ err = read_next_log_rec(log, lcb, &rec_lsn); if (err) @@ -5148,7 +5163,10 @@ out: if (lcb) lcb_put(lcb); - /* Scan the Open Attribute Table to close all of the open attributes */ + /* + * Scan the Open Attribute Table to close all of + * the open attributes. + */ oe = NULL; while ((oe = enum_rstbl(oatbl, oe))) { rno = ino_get(&oe->ref); |