Skip to content

Commit 94982e4

Browse files
authored
[sync] support of DFSv2 (#27)
## Changes * Support of DFSv2 Synchronization from upstream: * fixed commented doxygen syntax mismatch; * used environment variables in install directory; * ext4_fs.c has an additional `CONFIG_EXTENTS_ENABLE` affect. Since this item is not additionally configured, and the default value has no effect on compilation conditions, no code was actually changed.
1 parent a94fe63 commit 94982e4

28 files changed

Lines changed: 1054 additions & 438 deletions

SConscript

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ src/ext4_ialloc.c
2020
src/ext4_inode.c
2121
src/ext4_journal.c
2222
src/ext4_mkfs.c
23+
src/ext4_mp.c
2324
src/ext4_super.c
2425
src/ext4_trans.c
2526
src/ext4_xattr.c
@@ -32,7 +33,7 @@ CPPDEFINES = ['CONFIG_USE_DEFAULT_CFG', 'CONFIG_HAVE_OWN_OFLAGS=0']
3233

3334
LOCAL_CCFLAGS = ''
3435

35-
group = DefineGroup('Filesystem', objs,
36+
group = DefineGroup('Filesystem', objs,
3637
depend = ['RT_USING_DFS', 'RT_USING_DFS_LWEXT4'],
3738
CPPPATH = CPPPATH,
3839
CPPDEFINES = CPPDEFINES,

fs_test/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ add_executable(lwext4-mbr lwext4_mbr.c)
2424
target_link_libraries(lwext4-mbr blockdev)
2525
target_link_libraries(lwext4-mbr lwext4)
2626

27-
install (TARGETS lwext4-server DESTINATION /usr/bin)
28-
install (TARGETS lwext4-client DESTINATION /usr/bin)
29-
install (TARGETS lwext4-generic DESTINATION /usr/bin)
30-
install (TARGETS lwext4-mkfs DESTINATION /usr/bin)
31-
install (TARGETS lwext4-mbr DESTINATION /usr/bin)
27+
install (TARGETS lwext4-server DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
28+
install (TARGETS lwext4-client DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
29+
install (TARGETS lwext4-generic DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
30+
install (TARGETS lwext4-mkfs DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
31+
install (TARGETS lwext4-mbr DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
3232

include/ext4.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ extern "C" {
5050
#include <ext4_errno.h>
5151
#include <ext4_oflags.h>
5252
#include <ext4_debug.h>
53+
#include <ext4_inode.h>
54+
#include <ext4_fs.h>
5355

5456
#include <ext4_blockdev.h>
5557

@@ -123,6 +125,13 @@ int ext4_mount(struct ext4_blockdev *bd,
123125
const char *mount_point,
124126
bool read_only);
125127

128+
/**@brief Umount operation.
129+
*
130+
* @param mount_point Mount point.
131+
*
132+
* @return Standard error code */
133+
int ext4_umount_mp(struct ext4_mountpoint *mp);
134+
126135
/**@brief Umount operation.
127136
*
128137
* @param mount_pount Mount point.
@@ -140,23 +149,23 @@ int ext4_umount(const char *mount_point);
140149
*
141150
* ext4_journal_stop("/");
142151
* ext4_umount("/");
143-
* @param mount_pount Mount point.
152+
* @param mount_point Mount point.
144153
*
145154
* @return Standard error code. */
146155
int ext4_journal_start(const char *mount_point);
147156

148157
/**@brief Stops journaling. Journaling start/stop functions are transparent
149158
* and might be used on filesystems without journaling support.
150159
*
151-
* @param mount_pount Mount point name.
160+
* @param mount_point Mount point name.
152161
*
153162
* @return Standard error code. */
154163
int ext4_journal_stop(const char *mount_point);
155164

156165
/**@brief Journal recovery.
157166
* @warning Must be called after @ref ext4_mount.
158167
*
159-
* @param mount_pount Mount point.
168+
* @param mount_point Mount point.
160169
*
161170
* @return Standard error code. */
162171
int ext4_recover(const char *mount_point);
@@ -178,7 +187,7 @@ struct ext4_mount_stats {
178187

179188
/**@brief Get file mount point stats.
180189
*
181-
* @param mount_pount Mount point.
190+
* @param mount_point Mount point.
182191
* @param stats Filesystem stats.
183192
*
184193
* @return Standard error code. */
@@ -187,7 +196,7 @@ int ext4_mount_point_stats(const char *mount_point,
187196

188197
/**@brief Setup OS lock routines.
189198
*
190-
* @param mount_pount Mount point.
199+
* @param mount_point Mount point.
191200
* @param locks Lock and unlock functions
192201
*
193202
* @return Standard error code. */
@@ -196,7 +205,7 @@ int ext4_mount_setup_locks(const char *mount_point,
196205

197206
/**@brief Acquire the filesystem superblock pointer of a mp.
198207
*
199-
* @param mount_pount Mount point.
208+
* @param mount_point Mount point.
200209
* @param sb Superblock handle
201210
*
202211
* @return Standard error code. */
@@ -233,7 +242,7 @@ int ext4_get_sblock(const char *mount_point, struct ext4_sblock **sb);
233242
* Write back mode is useful when you want to create a lot of empty
234243
* files/directories.
235244
*
236-
* @param mount_pount Mount point.
245+
* @param path Mount point.
237246
* @param on Enable/disable cache writeback mode.
238247
*
239248
* @return Standard error code. */
@@ -242,7 +251,7 @@ int ext4_cache_write_back(const char *path, bool on);
242251

243252
/**@brief Force cache flush.
244253
*
245-
* @param mount_pount Mount point.
254+
* @param path Mount point.
246255
*
247256
* @return Standard error code. */
248257
int ext4_cache_flush(const char *path);
@@ -390,6 +399,9 @@ int ext4_raw_inode_fill(const char *path, uint32_t *ret_ino,
390399
* @return Standard error code.*/
391400
int ext4_inode_exist(const char *path, int type);
392401

402+
void* ext4_get_inode_ref(const char *path, struct ext4_inode_ref *ref);
403+
int ext4_put_inode_ref(struct ext4_mountpoint *mp, struct ext4_inode_ref *ref);
404+
393405
/**@brief Change file/directory/link mode bits.
394406
*
395407
* @param path Path to file/dir/link.
@@ -517,8 +529,8 @@ int ext4_setxattr(const char *path, const char *name, size_t name_len,
517529
* @param path Path to file/directory.
518530
* @param name Name of the entry to get.
519531
* @param name_len Length of @name in bytes.
520-
* @param data Data of the entry to get.
521-
* @param data_size Size of data to get.
532+
* @param buf Data of the entry to get.
533+
* @param buf_size Size of data to get.
522534
*
523535
* @return Standard error code.*/
524536
int ext4_getxattr(const char *path, const char *name, size_t name_len,

include/ext4_balloc.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ extern "C" {
5454
#include <stdbool.h>
5555

5656
/**@brief Compute number of block group from block address.
57-
* @param sb superblock pointer.
57+
* @param s superblock pointer.
5858
* @param baddr Absolute address of block.
5959
* @return Block group index
6060
*/
6161
uint32_t ext4_balloc_get_bgid_of_block(struct ext4_sblock *s,
6262
ext4_fsblk_t baddr);
6363

6464
/**@brief Compute the starting block address of a block group
65-
* @param sb superblock pointer.
65+
* @param s superblock pointer.
6666
* @param bgid block group index
6767
* @return Block address
6868
*/
@@ -95,7 +95,6 @@ int ext4_balloc_free_blocks(struct ext4_inode_ref *inode_ref,
9595

9696
/**@brief Allocate block procedure.
9797
* @param inode_ref inode reference
98-
* @param goal
9998
* @param baddr allocated block address
10099
* @return standard error code*/
101100
int ext4_balloc_alloc_block(struct ext4_inode_ref *inode_ref,

include/ext4_bcache.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ struct ext4_buf {
8484

8585
/**@brief Reference count table*/
8686
uint32_t refctr;
87+
/* refcount for read */
88+
uint32_t read_refctr;
8789

8890
/**@brief The block cache this buffer belongs to. */
8991
struct ext4_bcache *bc;
@@ -185,9 +187,11 @@ static inline void ext4_bcache_clear_dirty(struct ext4_buf *buf) {
185187

186188
/**@brief Increment reference counter of buf by 1.*/
187189
#define ext4_bcache_inc_ref(buf) ((buf)->refctr++)
190+
#define ext4_bcache_inc_read_ref(buf) ((buf)->read_refctr++)
188191

189192
/**@brief Decrement reference counter of buf by 1.*/
190193
#define ext4_bcache_dec_ref(buf) ((buf)->refctr--)
194+
#define ext4_bcache_dec_read_ref(buf) ((buf)->read_refctr--)
191195

192196
/**@brief Insert buffer to dirty cache list
193197
* @param bc block cache descriptor
@@ -248,8 +252,7 @@ void ext4_bcache_invalidate_buf(struct ext4_bcache *bc,
248252
/**@brief Invalidate a range of buffers.
249253
* @param bc block cache descriptor
250254
* @param from starting lba
251-
* @param cnt block counts
252-
* @param buf buffer*/
255+
* @param cnt block counts*/
253256
void ext4_bcache_invalidate_lba(struct ext4_bcache *bc,
254257
uint64_t from,
255258
uint32_t cnt);

include/ext4_block_group.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ static inline uint64_t ext4_bg_get_block_bitmap(struct ext4_bgroup *bg,
7373
* @param bg pointer to block group
7474
* @param s pointer to superblock
7575
* @param blk block to set
76-
* @return Address of block with block bitmap
7776
*/
7877
static inline void ext4_bg_set_block_bitmap(struct ext4_bgroup *bg,
7978
struct ext4_sblock *s, uint64_t blk)
@@ -106,7 +105,6 @@ static inline uint64_t ext4_bg_get_inode_bitmap(struct ext4_bgroup *bg,
106105
* @param bg Pointer to block group
107106
* @param s Pointer to superblock
108107
* @param blk block to set
109-
* @return Address of block with i-node bitmap
110108
*/
111109
static inline void ext4_bg_set_inode_bitmap(struct ext4_bgroup *bg,
112110
struct ext4_sblock *s, uint64_t blk)
@@ -139,7 +137,6 @@ ext4_bg_get_inode_table_first_block(struct ext4_bgroup *bg,
139137
* @param bg Pointer to block group
140138
* @param s Pointer to superblock
141139
* @param blk block to set
142-
* @return Address of first block of i-node table
143140
*/
144141
static inline void
145142
ext4_bg_set_inode_table_first_block(struct ext4_bgroup *bg,
@@ -152,7 +149,7 @@ ext4_bg_set_inode_table_first_block(struct ext4_bgroup *bg,
152149

153150
/**@brief Get number of free blocks in block group.
154151
* @param bg Pointer to block group
155-
* @param sb Pointer to superblock
152+
* @param s Pointer to superblock
156153
* @return Number of free blocks in block group
157154
*/
158155
static inline uint32_t ext4_bg_get_free_blocks_count(struct ext4_bgroup *bg,
@@ -282,7 +279,7 @@ static inline void ext4_bg_set_checksum(struct ext4_bgroup *bg, uint16_t crc)
282279

283280
/**@brief Check if block group has a flag.
284281
* @param bg Pointer to block group
285-
* @param flag Flag to be checked
282+
* @param f Flag to be checked
286283
* @return True if flag is set to 1
287284
*/
288285
static inline bool ext4_bg_has_flag(struct ext4_bgroup *bg, uint32_t f)
@@ -292,7 +289,7 @@ static inline bool ext4_bg_has_flag(struct ext4_bgroup *bg, uint32_t f)
292289

293290
/**@brief Set flag of block group.
294291
* @param bg Pointer to block group
295-
* @param flag Flag to be set
292+
* @param f Flag to be set
296293
*/
297294
static inline void ext4_bg_set_flag(struct ext4_bgroup *bg, uint32_t f)
298295
{
@@ -303,7 +300,7 @@ static inline void ext4_bg_set_flag(struct ext4_bgroup *bg, uint32_t f)
303300

304301
/**@brief Clear flag of block group.
305302
* @param bg Pointer to block group
306-
* @param flag Flag to be cleared
303+
* @param f Flag to be cleared
307304
*/
308305
static inline void ext4_bg_clear_flag(struct ext4_bgroup *bg, uint32_t f)
309306
{

include/ext4_blockdev.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ struct ext4_blockdev {
153153
}
154154

155155
/**@brief Block device initialization.
156-
* @param bdev block device descriptor
157-
* @param bg_bsize logical block size
158156
* @param bdev block device descriptor
159157
* @return standard error code*/
160158
int ext4_block_init(struct ext4_blockdev *bdev);
@@ -185,8 +183,7 @@ int ext4_block_flush_lba(struct ext4_blockdev *bdev, uint64_t lba);
185183

186184
/**@brief Set logical block size in block device.
187185
* @param bdev block device descriptor
188-
* @param lb_size logical block size (in bytes)
189-
* @return standard error code*/
186+
* @param lb_bsize logical block size (in bytes)*/
190187
void ext4_block_set_lb_size(struct ext4_blockdev *bdev, uint32_t lb_bsize);
191188

192189
/**@brief Block get function (through cache, don't read).

include/ext4_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ extern "C" {
147147

148148
/**@brief Maximum mountpoint count*/
149149
#ifndef CONFIG_EXT4_MOUNTPOINTS_COUNT
150-
#define CONFIG_EXT4_MOUNTPOINTS_COUNT 4
150+
#define CONFIG_EXT4_MOUNTPOINTS_COUNT 20
151151
#endif
152152

153153
/**@brief Include open flags from ext4_errno or standard library.*/

include/ext4_crc32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ uint32_t ext4_crc32(uint32_t crc, const void *buf, uint32_t size);
5757
/**@brief CRC32C algorithm.
5858
* @param crc input feed
5959
* @param buf input buffer
60-
* @param length input buffer length (bytes)
60+
* @param size input buffer length (bytes)
6161
* @return updated crc32c value*/
6262
uint32_t ext4_crc32c(uint32_t crc, const void *buf, uint32_t size);
6363

include/ext4_debug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ static inline const char *ext4_dmask_id2str(uint32_t m)
139139
#define DBG_ERROR "[error] "
140140

141141
/**@brief Global mask debug set.
142-
* @brief m new debug mask.*/
142+
* @param m new debug mask.*/
143143
void ext4_dmask_set(uint32_t m);
144144

145145
/**@brief Global mask debug clear.
146-
* @brief m new debug mask.*/
146+
* @param m new debug mask.*/
147147
void ext4_dmask_clr(uint32_t m);
148148

149149
/**@brief Global debug mask get.

0 commit comments

Comments
 (0)