Conversation
befb20a to
c0aeabf
Compare
amissael95
left a comment
There was a problem hiding this comment.
Thanks for you efforts and working in this change. Leaving a couple of comments. Please ensure the fix is tested and documented in this PR properly.
| // TODO: Add logs to this thing | ||
| if (ret < 0) { | ||
| if (IS_WRITE_PERM(-ret)) { | ||
| mam_lockval vollock = d->matches_name_criteria ? PWE_MAM_IP : PWE_MAM_DP; |
There was a problem hiding this comment.
Fix indentation please.
c0aeabf to
6a00127
Compare
6a00127 to
0f0a343
Compare
c5d658a to
decdff8
Compare
| } | ||
|
|
||
| return ret; | ||
| return ret > (ssize_t)size? (ssize_t)size : ret; |
There was a problem hiding this comment.
This was also done before this PR change in lines 233 - 334. It looks like it is done to ensure than the return value is always equal to the number of bytes (size variable) wanted to be written, this is in case unified_write returns more bytes than the bytes wanted to write because a "bug":
* @param size Number of bytes to write.
*[...]
* @return Number of bytes written on success, or a negative value on error. The number of
* bytes written on success always equals 'size'; any other nonnegative return value from
* this function is a bug. In the future, the scheduler write interface may change to
* return 0 on success.
*/
ssize_t unified_write(struct dentry *d, const char *buf, size_t size, off_t offset,Could you confirm it? Do you have more context of how that bug can be generated/triggered?
fix: NO_SENSE errortype when it should be backwards fix: unified simple problems
decdff8 to
57515dd
Compare
syaoraang
left a comment
There was a problem hiding this comment.
Overall, they seem pretty good changes, and a good way to overcome the dependency hell for some cases, but I think it can be improved and some stuffs need to be addressed.
| */ | ||
|
|
||
| #include "ltfs.h" | ||
| #include "ltfs_error.h" |
There was a problem hiding this comment.
Not necessary header, please remove it.
| if (ret < 0) | ||
| return ret; | ||
| else | ||
| return 0; | ||
| return ret < 0? ret : 0; |
There was a problem hiding this comment.
Works, but it's not necessary to change it since it's already working and this does not changes the behavior.
| return -EDEV_NO_SENSE; | ||
| return -EDEV_WRITE_PERM; | ||
| else | ||
| return -EDEV_WRITE_PERM; | ||
| return -EDEV_NO_SENSE; |
There was a problem hiding this comment.
Nice catch!
But please fix indentation
|
|
||
| #include "fs.h" | ||
| #include "ltfs.h" | ||
| #include "ltfs_error.h" |
There was a problem hiding this comment.
Not necessary headder add.
| /* Position mismatch, diff not equal zero */ | ||
| ltfsmsg(LTFS_INFO, 17293E, (unsigned long long)physical_selfptr.block, (unsigned long long)current_position.block); | ||
| return -1; | ||
| return -LTFS_INDEX_INVALID; |
There was a problem hiding this comment.
This return value doesn't match with LTFS_INDEX_INVALID definition, besides the comment for this part specifies to return -1, if we change this return value, we should update the comment
| if (volstat == PWE_MAM_DP && partition == ltfs_ip_id(vol)) | ||
| new_volstat = PWE_MAM_BOTH; | ||
| else if (volstat == PWE_MAM_IP && partition == ltfs_dp_id(vol)) | ||
| new_volstat = PWE_MAM_BOTH; | ||
| else if (volstat == UNLOCKED_MAM && partition == ltfs_ip_id(vol)) | ||
| new_volstat = PWE_MAM_IP; | ||
| else if (volstat == UNLOCKED_MAM && partition == ltfs_dp_id(vol)) | ||
| new_volstat = PWE_MAM_DP; |
There was a problem hiding this comment.
I see that the MAM status gotten from volstats is managed in iosched_write(), but this function (ltfs_write_index()) is also called from other functions such as fuse's mount and unmount and some others.
So, we're loosing this status' management and the possible lock.
Is this expected?
| ** | ||
| ************************************************************************************* | ||
| */ | ||
| #include "ltfs_error.h" |
| /* Index partition writer: failed to write data to the tape (%d) */ | ||
| ltfsmsg(LTFS_WARN, 13013W, (int)ret); | ||
| if (IS_WRITE_PERM(-ret)) { | ||
| ret = tape_set_cart_volume_lock_status(priv->vol, PWE_MAM_IP); |
There was a problem hiding this comment.
Since this is under the unified and the lock is now in the iosched, we'll lose those guards.
Is this intended?
| if (ret < 0) { | ||
| /* Data partition writer: failed to write data to the tape (%d) */ | ||
| ltfsmsg(LTFS_WARN, 13014W, (int)ret); | ||
| (void)_unified_write_index_after_perm(ret, priv); |
There was a problem hiding this comment.
Since this is under the unified and the catch of the perm is now in the iosched, we'll lose that behavior.
Is this intended?
This applies for next 3 changes
| uint64_t last_index_pos = UINT64_MAX; | ||
| unsigned long blocksize; | ||
|
|
||
| if (!IS_WRITE_PERM(-write_ret)) { |
There was a problem hiding this comment.
This check is unnecessary if this is going to be used like below, you do the check IS_WRITE_PERM and inside you call this function
fix: file backend NO_SENSE errortype when it should be backwards
fix: unified simple problems
Changelog
Fixed
Race Condition in Device Error Propagation
iosched.cto prevent inconsistent error states across multiple code pathsError Type Correction in File Debug Driver
filedebug_tc.cwhereNO_SENSEandWRITE_PERMerror types were reversedEDEV_WRITE_PERMwhenforce_errortypeis set, andEDEV_NO_SENSEotherwiseWrite Permission Error Handling
Changed
Code Refactoring
_unified_write_index_after_permfunction fromunified.ctoiosched.cas_iosched_write_index_after_permltfs_fsops_writefunctionError Handling Architecture
ltfs_write_indexfunctionAdded
New Error Checking Macro
IS_RW_PERMmacro inltfs_error.hfor checking read/write permission errorsChecklist: