io.c (32de74a1ac188cef3b996a65954d5b87128a4368) | io.c (307261b243df2edde538f3ed5c9d80e168529355) |
---|---|
1/* 2 * Block layer I/O functions 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 1959 unchanged lines hidden (view full) --- 1968static inline int coroutine_fn 1969bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes, 1970 BdrvTrackedRequest *req, int flags) 1971{ 1972 BlockDriverState *bs = child->bs; 1973 1974 bdrv_check_request(offset, bytes, &error_abort); 1975 | 1/* 2 * Block layer I/O functions 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 1959 unchanged lines hidden (view full) --- 1968static inline int coroutine_fn 1969bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes, 1970 BdrvTrackedRequest *req, int flags) 1971{ 1972 BlockDriverState *bs = child->bs; 1973 1974 bdrv_check_request(offset, bytes, &error_abort); 1975 |
1976 if (bs->read_only) { | 1976 if (bdrv_is_read_only(bs)) { |
1977 return -EPERM; 1978 } 1979 1980 assert(!(bs->open_flags & BDRV_O_INACTIVE)); 1981 assert((bs->open_flags & BDRV_O_NO_IO) == 0); 1982 assert(!(flags & ~BDRV_REQ_MASK)); 1983 assert(!((flags & BDRV_REQ_NO_WAIT) && !(flags & BDRV_REQ_SERIALISING))); 1984 --- 1416 unchanged lines hidden (view full) --- 3401 BDRV_TRACKED_TRUNCATE); 3402 3403 /* If we are growing the image and potentially using preallocation for the 3404 * new area, we need to make sure that no write requests are made to it 3405 * concurrently or they might be overwritten by preallocation. */ 3406 if (new_bytes) { 3407 bdrv_make_request_serialising(&req, 1); 3408 } | 1977 return -EPERM; 1978 } 1979 1980 assert(!(bs->open_flags & BDRV_O_INACTIVE)); 1981 assert((bs->open_flags & BDRV_O_NO_IO) == 0); 1982 assert(!(flags & ~BDRV_REQ_MASK)); 1983 assert(!((flags & BDRV_REQ_NO_WAIT) && !(flags & BDRV_REQ_SERIALISING))); 1984 --- 1416 unchanged lines hidden (view full) --- 3401 BDRV_TRACKED_TRUNCATE); 3402 3403 /* If we are growing the image and potentially using preallocation for the 3404 * new area, we need to make sure that no write requests are made to it 3405 * concurrently or they might be overwritten by preallocation. */ 3406 if (new_bytes) { 3407 bdrv_make_request_serialising(&req, 1); 3408 } |
3409 if (bs->read_only) { | 3409 if (bdrv_is_read_only(bs)) { |
3410 error_setg(errp, "Image is read-only"); 3411 ret = -EACCES; 3412 goto out; 3413 } 3414 ret = bdrv_co_write_req_prepare(child, offset - new_bytes, new_bytes, &req, 3415 0); 3416 if (ret < 0) { 3417 error_setg_errno(errp, -ret, --- 78 unchanged lines hidden --- | 3410 error_setg(errp, "Image is read-only"); 3411 ret = -EACCES; 3412 goto out; 3413 } 3414 ret = bdrv_co_write_req_prepare(child, offset - new_bytes, new_bytes, &req, 3415 0); 3416 if (ret < 0) { 3417 error_setg_errno(errp, -ret, --- 78 unchanged lines hidden --- |