Skip to content

Commit

Permalink
Trunk Build 847
Browse files Browse the repository at this point in the history
  • Loading branch information
datalight-devops committed Oct 22, 2019
1 parent 2bfba4e commit c27ee8d
Show file tree
Hide file tree
Showing 48 changed files with 501 additions and 101 deletions.
7 changes: 5 additions & 2 deletions core/driver/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,17 @@ REDSTATUS RedCoreVolFormat(void)
If the volume is already mounted, the behavior is undefined.
@param ulFlags A bitwise-OR'd mask of mount flags.
@return A negated ::REDSTATUS code indicating the operation result.
@retval 0 Operation was successful.
@retval -RED_EIO Volume not formatted, improperly formatted, or corrupt.
*/
REDSTATUS RedCoreVolMount(void)
REDSTATUS RedCoreVolMount(
uint32_t ulFlags)
{
return RedVolMount();
return RedVolMount(ulFlags);
}


Expand Down
6 changes: 6 additions & 0 deletions core/driver/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ REDSTATUS RedVolFormat(void)
MASTERBLOCK *pMB;
REDSTATUS ret2;

/* fReadOnly might still be true from the last time the volume was
mounted (or from the checker). Clear it now to avoid assertions in
lower-level code.
*/
gpRedVolume->fReadOnly = false;

/* Overwrite the master block with zeroes, so that if formatting is
interrupted, the volume will not be mountable.
*/
Expand Down
61 changes: 40 additions & 21 deletions core/driver/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,53 @@ static void MetaRootEndianSwap(METAROOT *pMetaRoot);

/** @brief Mount a file system volume.
@param ulFlags A bitwise-OR'd mask of mount flags.
@return A negated ::REDSTATUS code indicating the operation result.
@retval 0 Operation was successful.
@retval -RED_EINVAL @p ulFlags includes invalid mount flags.
@retval -RED_EIO Volume not formatted, improperly formatted, or corrupt.
*/
REDSTATUS RedVolMount(void)
REDSTATUS RedVolMount(
uint32_t ulFlags)
{
REDSTATUS ret;

#if REDCONF_READ_ONLY == 0
ret = RedOsBDevOpen(gbRedVolNum, BDEV_O_RDWR);
#else
ret = RedOsBDevOpen(gbRedVolNum, BDEV_O_RDONLY);
#endif
REDSTATUS ret;

if(ret == 0)
if(ulFlags != (ulFlags & RED_MOUNT_MASK))
{
ret = RedVolMountMaster();
ret = -RED_EINVAL;
}
else
{
BDEVOPENMODE mode = BDEV_O_RDONLY;

if(ret == 0)
#if REDCONF_READ_ONLY == 0
if((ulFlags & RED_MOUNT_READONLY) == 0U)
{
ret = RedVolMountMetaroot();
mode = BDEV_O_RDWR;
}
#endif

ret = RedOsBDevOpen(gbRedVolNum, mode);

if(ret != 0)
if(ret == 0)
{
/* If we fail to mount, invalidate the buffers to prevent any
confusion that could be caused by stale or corrupt metadata.
*/
(void)RedBufferDiscardRange(0U, gpRedVolume->ulBlockCount);
(void)RedOsBDevClose(gbRedVolNum);
ret = RedVolMountMaster();

if(ret == 0)
{
ret = RedVolMountMetaroot(ulFlags);
}

if(ret != 0)
{
/* If we fail to mount, invalidate the buffers to prevent any
confusion that could be caused by stale or corrupt metadata.
*/
(void)RedBufferDiscardRange(0U, gpRedVolume->ulBlockCount);
(void)RedOsBDevClose(gbRedVolNum);
}
}
}

Expand Down Expand Up @@ -146,14 +162,17 @@ REDSTATUS RedVolMountMaster(void)
This function also populates the volume contexts.
@param ulFlags A bitwise-OR'd mask of mount flags.
@return A negated ::REDSTATUS code indicating the operation result.
@retval 0 Operation was successful.
@retval -RED_EIO Both metaroots are missing or corrupt.
*/
REDSTATUS RedVolMountMetaroot(void)
REDSTATUS RedVolMountMetaroot(
uint32_t ulFlags)
{
REDSTATUS ret;
REDSTATUS ret;

ret = RedIoRead(gbRedVolNum, BLOCK_NUM_FIRST_METAROOT, 1U, &gpRedCoreVol->aMR[0U]);

Expand Down Expand Up @@ -253,7 +272,7 @@ REDSTATUS RedVolMountMetaroot(void)
{
gpRedVolume->fMounted = true;
#if REDCONF_READ_ONLY == 0
gpRedVolume->fReadOnly = false;
gpRedVolume->fReadOnly = (ulFlags & RED_MOUNT_READONLY) != 0U;
#endif

#if RESERVED_BLOCKS > 0U
Expand Down
4 changes: 2 additions & 2 deletions core/include/redcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ REDSTATUS RedDirEntryRename(CINODE *pSrcPInode, const char *pszSrcName, CINODE *
#endif
#endif

REDSTATUS RedVolMount(void);
REDSTATUS RedVolMount(uint32_t ulFlags);
REDSTATUS RedVolMountMaster(void);
REDSTATUS RedVolMountMetaroot(void);
REDSTATUS RedVolMountMetaroot(uint32_t ulFlags);
#if REDCONF_READ_ONLY == 0
REDSTATUS RedVolTransact(void);
#endif
Expand Down
21 changes: 21 additions & 0 deletions doc/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ recent releases and a list of known issues.

## Release History and Changes

### Reliance Edge v2.4 (Beta), October 2019

This is a preview release that contains a subset of the changes planned for
Reliance Edge v2.4; when v2.4 is released it will supersede this beta release.

#### Common Code Changes

- Add red_mount2() to the POSIX-like API. It is similar to red_mount() except
that mount flags can be specified. Flags are provided for mounting read-only
and to control whether discards are issued.
- Add red_fstrim() to the POSIX-like API (commercial kit only). The API is used
to discard free space, similar to the fstrim utility on Linux systems.
- The `REDCONF_API_POSIX_FSTRIM` macro has been added to redconf.h to specify
whether red_fstrim() should be included. Existing redconf.h files must be
updated by opening and saving them with the updated Configuration Utility.
- RedOsBDevDiscard() (which only exists in the commercial kit) has been updated
to return a `REDSTATUS` value, instead of returning `void`.
- red_sync() and red_close() have been fixed to work with read-only volumes.
- MVStressTest, a new stress test that can exercise multiple file system
volumes, has been added to the commercial kit.

### Reliance Edge v2.3, January 2019

#### Common Code Changes
Expand Down
25 changes: 25 additions & 0 deletions doc/release_notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@ course of recent releases and a list of known issues.

Release History and Changes

Reliance Edge v2.4 (Beta), October 2019

This is a preview release that contains a subset of the changes planned
for Reliance Edge v2.4; when v2.4 is released it will supersede this
beta release.

Common Code Changes

- Add red_mount2() to the POSIX-like API. It is similar to red_mount()
except that mount flags can be specified. Flags are provided for
mounting read-only and to control whether discards are issued.
- Add red_fstrim() to the POSIX-like API (commercial kit only). The
API is used to discard free space, similar to the fstrim utility on
Linux systems.
- The REDCONF_API_POSIX_FSTRIM macro has been added to redconf.h to
specify whether red_fstrim() should be included. Existing redconf.h
files must be updated by opening and saving them with the updated
Configuration Utility.
- RedOsBDevDiscard() (which only exists in the commercial kit) has
been updated to return a REDSTATUS value, instead of returning void.
- red_sync() and red_close() have been fixed to work with read-only
volumes.
- MVStressTest, a new stress test that can exercise multiple file
system volumes, has been added to the commercial kit.

Reliance Edge v2.3, January 2019

Common Code Changes
Expand Down
2 changes: 1 addition & 1 deletion fse/fse.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ REDSTATUS RedFseMount(
{
if(!gpRedVolume->fMounted)
{
ret = RedCoreVolMount();
ret = RedCoreVolMount(RED_MOUNT_DEFAULT);
}

FseLeave();
Expand Down
26 changes: 25 additions & 1 deletion include/redapimacs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@
#define REDAPIMACS_H


/** Mount the volume as read-only. */
#define RED_MOUNT_READONLY 0x00000001U

/** Mount the volume with automatic discards enabled. */
#define RED_MOUNT_DISCARD 0x00000002U

#if REDCONF_READ_ONLY == 0
/** Mask of all supported mount flags. */
#define RED_MOUNT_MASK (RED_MOUNT_READONLY | RED_MOUNT_DISCARD)
#else
/** Mask of all supported mount flags. */
#define RED_MOUNT_MASK RED_MOUNT_READONLY
#endif

/** @brief Default mount flags.
These are the mount flags that are used when Reliance Edge is mounted via an
API which does not allow mount flags to be specified: viz., red_mount() or
RedFseMount(). If red_mount2() is used, the flags provided to it supersede
these flags.
*/
#define RED_MOUNT_DEFAULT (RED_MOUNT_DISCARD & RED_MOUNT_MASK)


/** Clear all events: manual transactions only. */
#define RED_TRANSACT_MANUAL 0x00000000U

Expand Down Expand Up @@ -70,7 +94,7 @@

#if REDCONF_READ_ONLY == 1

/** Mask of all supported automatic transaction events. */
/** @brief Mask of all supported automatic transaction events. */
#define RED_TRANSACT_MASK 0U

#elif REDCONF_API_POSIX == 1
Expand Down
25 changes: 21 additions & 4 deletions include/redconfigchk.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@
#ifndef REDCONF_API_POSIX_CWD
#error "Configuration error: REDCONF_API_POSIX_CWD must be defined."
#endif
#ifndef REDCONF_API_POSIX_FSTRIM
/* Reliance Edge v2.3 and below did not have REDCONF_API_POSIX_FSTRIM. You
can fix this error by downloading the latest version of the
Configuration Utility (assuming you are using the latest version of
Reliance Edge) from http://www.datalight.com/reliance-edge, loading your
redconf.c and redconf.h files, and saving them again, replacing the
original files.
*/
#error "Configuration error: your redconf.h is not compatible. Update your redconf files with a compatible version of the configuration utility."
#endif
#ifndef REDCONF_NAME_MAX
#error "Configuration error: REDCONF_NAME_MAX must be defined."
#endif
Expand Down Expand Up @@ -231,6 +241,13 @@
#error "Configuration error: REDCONF_API_POSIX_CWD must be either 0 or 1."
#endif

#if (REDCONF_API_POSIX_FSTRIM != 0) && (REDCONF_API_POSIX_FSTRIM != 1)
#error "Configuration error: REDCONF_API_POSIX_FSTRIM must be either 0 or 1."
#endif
#if (REDCONF_API_POSIX_FSTRIM == 1) && (RED_KIT == RED_KIT_GPL)
#error "REDCONF_API_POSIX_FSTRIM not supported in Reliance Edge under GPL. Contact [email protected] to upgrade."
#endif

#if (REDCONF_NAME_MAX < 1U) || (REDCONF_NAME_MAX > (REDCONF_BLOCK_SIZE - 4U))
#error "Configuration error: invalid value of REDCONF_NAME_MAX"
#endif
Expand Down Expand Up @@ -333,6 +350,10 @@
#error "Configuration error: REDCONF_DISCARDS must be either 0 or 1."
#endif

#if (REDCONF_DISCARDS == 1) && (RED_KIT == RED_KIT_GPL)
#error "REDCONF_DISCARDS not supported in Reliance Edge under GPL. Contact [email protected] to upgrade."
#endif

/* REDCONF_BUFFER_COUNT lower limit checked in buffer.c
*/
#if REDCONF_BUFFER_COUNT > 255U
Expand All @@ -347,10 +368,6 @@
#error "Configuration error: REDCONF_CHECKER must be either 0 or 1."
#endif

#if (REDCONF_DISCARDS == 1) && (RED_KIT == RED_KIT_GPL)
#error "REDCONF_DISCARDS not supported in Reliance Edge under GPL. Contact [email protected] to upgrade."
#endif


#endif

Expand Down
2 changes: 1 addition & 1 deletion include/redcoreapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ REDSTATUS RedCoreVolFormat(void);
#if REDCONF_CHECKER == 1
REDSTATUS RedCoreVolCheck(FILE *pOutputFile, char *pszOutputBuffer, uint32_t nOutputBufferSize);
#endif
REDSTATUS RedCoreVolMount(void);
REDSTATUS RedCoreVolMount(uint32_t ulFlags);
REDSTATUS RedCoreVolUnmount(void);
#if REDCONF_READ_ONLY == 0
REDSTATUS RedCoreVolTransact(void);
Expand Down
22 changes: 22 additions & 0 deletions include/reddeviations.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,27 @@
#define IS_ALIGNED_PTR(ptr) (((uintptr_t)(ptr) & (REDCONF_ALIGNMENT_SIZE - 1U)) == 0U)


/** @brief Ignore the return value of a discard function (cast to void)
Usages of this macro deviate from MISRA C:2012 Directive 4.7, which states
that error information must be checked immediately after a function returns
potential error information.
Two discard mechanisms exist which share common code at the lowest levels.
One mechanism, run-time discards, is an optimization, and thus errors are
non-fatal. The other mechanism, fstrim, is intended for use with a command
such as eMMC sanitize, with the goal of removing all previously deleted
data from the storage medium. In the fstrim case, errors should _not_ be
ignored, because if any of the discards fail, the sanitize will not remove
everything which was supposed to be removed. Since fstrim needs errors from
discards, the low-level discard routines return an error. Those same
routines are also used by run-time discard code which uses this macro to
ignore the errors.
As Directive 4.7 is required, a separate deviation record is required.
*/
#define IGNORE_DISCARD_ERRORS(fn) ((void) (fn))


#endif

3 changes: 3 additions & 0 deletions include/rederrno.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ typedef int32_t REDSTATUS;
/** Too many users. */
#define RED_EUSERS 87

/** Operation is not supported. */
#define RED_ENOTSUPP 524

/** Nothing will be okay ever again. */
#define RED_EFUBAR RED_EINVAL

Expand Down
6 changes: 6 additions & 0 deletions include/redexclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,11 @@
|| ((REDCONF_API_FSE == 1) && (REDCONF_API_FSE_FORMAT == 1)) \
|| (REDCONF_IMAGE_BUILDER == 1)))

#define DISCARD_SUPPORTED \
( \
(REDCONF_READ_ONLY == 0) \
&& ( ((REDCONF_API_POSIX == 1) && (REDCONF_API_POSIX_FSTRIM == 1)) \
|| (REDCONF_DISCARDS == 1)))

#endif

2 changes: 1 addition & 1 deletion include/redfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@


#include <redconf.h>
#include "redexclude.h"
#include "redver.h"
#include "redconfigchk.h"
#include <redtypes.h>
Expand All @@ -39,7 +40,6 @@
#include "redutils.h"
#include "redosserv.h"
#include "redmisc.h"
#include "redexclude.h"


#endif
Expand Down
3 changes: 3 additions & 0 deletions include/redmacs.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@
#endif

#define REDMIN(a, b) (((a) < (b)) ? (a) : (b))
#define REDMAX(a, b) (((a) > (b)) ? (a) : (b))

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(ARRAY) (sizeof(ARRAY) / sizeof((ARRAY)[0U]))
#endif

#define BITMAP_SIZE(bitcnt) (((bitcnt) + 7U) / 8U)

#define INODE_INVALID (0U) /* General-purpose invalid inode number (must be zero). */
#define INODE_FIRST_VALID (2U) /* First valid inode number. */
#define INODE_ROOTDIR (INODE_FIRST_VALID) /* Inode number of the root directory. */
Expand Down
Loading

0 comments on commit c27ee8d

Please sign in to comment.