On Wed, Jan 23, 2013 at 07:04:33PM +0800, Chen Yang wrote: > When sending a file with sparse or pre-allocated part, > these parts will be sent as ZERO streams, and it's unnecessary. > > To improve this, we add a punch command on the sending side, so the > receiving side changed with it. The main change is adding the punch > processing to receive command. > > +static int process_punch(const char *path, u64 offset, u64 len, void *user) > +{ > + int ret = 0; > + struct btrfs_receive *r = user; > + char *full_path = path_cat(r->full_subvol_path, path); > + > + ret = open_inode_for_write(r, full_path); > + if (ret < 0) > + goto out; > + > + ret = fallocate(r->write_fd, > + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, > + offset, len);
This unnecessarily fails if PUNCH_HOLE is not supported by the kernel version, some sort of fallback should be applied. > + if (ret < 0) { > + ret = -errno; > + fprintf(stderr, "ERROR: punch %s failed. %s\n", > + path, strerror(-ret)); > + goto out; > + } > + > +out: > + free(full_path); > + return ret; > +} david -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html