Changeset 9131690 in mainline


Ignore:
Timestamp:
2009-11-03T22:50:04Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3766467
Parents:
b1c21c2 (diff), dfddfcd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge FAT server I/O error handling improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_ops.c

    rb1c21c2 r9131690  
    363363                                }
    364364                                rc = fat_node_get_core(&nodep, idx);
    365                                 assert(rc == EOK);
    366365                                fibril_mutex_unlock(&idx->lock);
    367                                 (void) block_put(b);
     366                                if (rc != EOK) {
     367                                        (void) block_put(b);
     368                                        return rc;
     369                                }
    368370                                *rfn = FS_NODE(nodep);
    369                                 return EOK;
     371                                rc = block_put(b);
     372                                if (rc != EOK)
     373                                        (void) fat_node_put(*rfn);
     374                                return rc;
    370375                        }
    371376                }
     
    10721077                        rc = fat_block_get(&b, bs, nodep, pos / bps,
    10731078                            BLOCK_FLAGS_NONE);
    1074                         assert(rc == EOK);
     1079                        if (rc != EOK) {
     1080                                fat_node_put(fn);
     1081                                ipc_answer_0(callid, rc);
     1082                                ipc_answer_0(rid, rc);
     1083                                return;
     1084                        }
    10751085                        (void) async_data_read_finalize(callid, b->data + pos % bps,
    10761086                            bytes);
    10771087                        rc = block_put(b);
    1078                         assert(rc == EOK);
     1088                        if (rc != EOK) {
     1089                                fat_node_put(fn);
     1090                                ipc_answer_0(rid, rc);
     1091                                return;
     1092                        }
    10791093                }
    10801094        } else {
     
    11001114                        rc = fat_block_get(&b, bs, nodep, bnum,
    11011115                            BLOCK_FLAGS_NONE);
    1102                         assert(rc == EOK);
     1116                        if (rc != EOK)
     1117                                goto err;
    11031118                        for (o = pos % (bps / sizeof(fat_dentry_t));
    11041119                            o < bps / sizeof(fat_dentry_t);
     
    11111126                                case FAT_DENTRY_LAST:
    11121127                                        rc = block_put(b);
    1113                                         assert(rc == EOK);
     1128                                        if (rc != EOK)
     1129                                                goto err;
    11141130                                        goto miss;
    11151131                                default:
     
    11171133                                        fat_dentry_name_get(d, name);
    11181134                                        rc = block_put(b);
    1119                                         assert(rc == EOK);
     1135                                        if (rc != EOK)
     1136                                                goto err;
    11201137                                        goto hit;
    11211138                                }
    11221139                        }
    11231140                        rc = block_put(b);
    1124                         assert(rc == EOK);
     1141                        if (rc != EOK)
     1142                                goto err;
    11251143                        bnum++;
    11261144                }
    11271145miss:
    1128                 fat_node_put(fn);
    1129                 ipc_answer_0(callid, ENOENT);
    1130                 ipc_answer_1(rid, ENOENT, 0);
    1131                 return;
     1146                rc = fat_node_put(fn);
     1147                ipc_answer_0(callid, rc != EOK ? rc : ENOENT);
     1148                ipc_answer_1(rid, rc != EOK ? rc : ENOENT, 0);
     1149                return;
     1150
     1151err:
     1152                (void) fat_node_put(fn);
     1153                ipc_answer_0(callid, rc);
     1154                ipc_answer_0(rid, rc);
     1155                return;
     1156
    11321157hit:
    11331158                (void) async_data_read_finalize(callid, name, str_size(name) + 1);
     
    11351160        }
    11361161
    1137         fat_node_put(fn);
    1138         ipc_answer_1(rid, EOK, (ipcarg_t)bytes);
     1162        rc = fat_node_put(fn);
     1163        ipc_answer_1(rid, rc, (ipcarg_t)bytes);
    11391164}
    11401165
     
    11471172        fat_node_t *nodep;
    11481173        fat_bs_t *bs;
    1149         size_t bytes;
     1174        size_t bytes, size;
    11501175        block_t *b;
    11511176        uint16_t bps;
     
    11701195        size_t len;
    11711196        if (!async_data_write_receive(&callid, &len)) {
    1172                 fat_node_put(fn);
     1197                (void) fat_node_put(fn);
    11731198                ipc_answer_0(callid, EINVAL);
    11741199                ipc_answer_0(rid, EINVAL);
     
    12011226                 */
    12021227                rc = fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos);
    1203                 assert(rc == EOK);
     1228                if (rc != EOK) {
     1229                        (void) fat_node_put(fn);
     1230                        ipc_answer_0(callid, rc);
     1231                        ipc_answer_0(rid, rc);
     1232                        return;
     1233                }
    12041234                rc = fat_block_get(&b, bs, nodep, pos / bps, flags);
    1205                 assert(rc == EOK);
     1235                if (rc != EOK) {
     1236                        (void) fat_node_put(fn);
     1237                        ipc_answer_0(callid, rc);
     1238                        ipc_answer_0(rid, rc);
     1239                        return;
     1240                }
    12061241                (void) async_data_write_finalize(callid, b->data + pos % bps,
    12071242                    bytes);
    12081243                b->dirty = true;                /* need to sync block */
    12091244                rc = block_put(b);
    1210                 assert(rc == EOK);
     1245                if (rc != EOK) {
     1246                        (void) fat_node_put(fn);
     1247                        ipc_answer_0(rid, rc);
     1248                        return;
     1249                }
    12111250                if (pos + bytes > nodep->size) {
    12121251                        nodep->size = pos + bytes;
    12131252                        nodep->dirty = true;    /* need to sync node */
    12141253                }
    1215                 ipc_answer_2(rid, EOK, bytes, nodep->size);     
    1216                 fat_node_put(fn);
     1254                size = nodep->size;
     1255                rc = fat_node_put(fn);
     1256                ipc_answer_2(rid, rc, bytes, nodep->size);
    12171257                return;
    12181258        } else {
     
    12211261                 * clusters for the node and zero them out.
    12221262                 */
    1223                 int status;
    12241263                unsigned nclsts;
    12251264                fat_cluster_t mcl, lcl;
     
    12271266                nclsts = (ROUND_UP(pos + bytes, bpc) - boundary) / bpc;
    12281267                /* create an independent chain of nclsts clusters in all FATs */
    1229                 status = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);
    1230                 if (status != EOK) {
     1268                rc = fat_alloc_clusters(bs, dev_handle, nclsts, &mcl, &lcl);
     1269                if (rc != EOK) {
    12311270                        /* could not allocate a chain of nclsts clusters */
    1232                         fat_node_put(fn);
    1233                         ipc_answer_0(callid, status);
    1234                         ipc_answer_0(rid, status);
     1271                        (void) fat_node_put(fn);
     1272                        ipc_answer_0(callid, rc);
     1273                        ipc_answer_0(rid, rc);
    12351274                        return;
    12361275                }
    12371276                /* zero fill any gaps */
    12381277                rc = fat_fill_gap(bs, nodep, mcl, pos);
    1239                 assert(rc == EOK);
     1278                if (rc != EOK) {
     1279                        (void) fat_free_clusters(bs, dev_handle, mcl);
     1280                        (void) fat_node_put(fn);
     1281                        ipc_answer_0(callid, rc);
     1282                        ipc_answer_0(rid, rc);
     1283                        return;
     1284                }
    12401285                rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc,
    12411286                    flags);
    1242                 assert(rc == EOK);
     1287                if (rc != EOK) {
     1288                        (void) fat_free_clusters(bs, dev_handle, mcl);
     1289                        (void) fat_node_put(fn);
     1290                        ipc_answer_0(callid, rc);
     1291                        ipc_answer_0(rid, rc);
     1292                        return;
     1293                }
    12431294                (void) async_data_write_finalize(callid, b->data + pos % bps,
    12441295                    bytes);
    12451296                b->dirty = true;                /* need to sync block */
    12461297                rc = block_put(b);
    1247                 assert(rc == EOK);
     1298                if (rc != EOK) {
     1299                        (void) fat_free_clusters(bs, dev_handle, mcl);
     1300                        (void) fat_node_put(fn);
     1301                        ipc_answer_0(rid, rc);
     1302                        return;
     1303                }
    12481304                /*
    12491305                 * Append the cluster chain starting in mcl to the end of the
     
    12511307                 */
    12521308                rc = fat_append_clusters(bs, nodep, mcl);
    1253                 assert(rc == EOK);
    1254                 nodep->size = pos + bytes;
     1309                if (rc != EOK) {
     1310                        (void) fat_free_clusters(bs, dev_handle, mcl);
     1311                        (void) fat_node_put(fn);
     1312                        ipc_answer_0(rid, rc);
     1313                        return;
     1314                }
     1315                nodep->size = size = pos + bytes;
    12551316                nodep->dirty = true;            /* need to sync node */
    1256                 ipc_answer_2(rid, EOK, bytes, nodep->size);
    1257                 fat_node_put(fn);
     1317                rc = fat_node_put(fn);
     1318                ipc_answer_2(rid, rc, bytes, size);
    12581319                return;
    12591320        }
Note: See TracChangeset for help on using the changeset viewer.