On Thu, Apr 24, 2014 at 11:22:40AM -0600, Chris Murphy wrote: > > On Apr 24, 2014, at 9:55 AM, Hugo Mills wrote: > > > On Thu, Apr 24, 2014 at 09:23:28AM -0600, Chris Murphy wrote: > >> > >> > >> I don't understand the btrfs send -c man page text, or really even the use case. In part this is what it says: > >> > >>> You must not specify clone sources unless you > >>> guarantee that these snapshots are exactly in the same state on both > >>> sides, the sender and the receiver. > >> > >> If the snapshots are the same on both sides, then why would I be using clone in the first place? > > > > To copy over another snapshot which shares data with them. > > > >>> -c Use this snapshot as a clone source for an > >>> incremental send (multiple allowed) > >> > >> Incremental send implies the sender and receiver are not in the same state now, but will be after the command is executed. Is one, or both, snapshots rw for -c? > >> > >> Anyway, I'm lost on the specifics, but clearly I'm even lost when it comes to the basic difference between -p and -c. > > > > (Note: I've not actually tried the second case in what follows, but > > it's what I think is going on. This may be subject to corrections.) > > > > OK, call the sending system "S" and the receiving system "R". Let's > > say we've got three subvolumes on S: > > > > S:A2, the current /home (say) > > S:A1, a snapshot of an earlier version of S:A2 > > S:B, a separate subvolume that's had some CoW copies of files in both > > S:A1 and S:A2 made into it. > > > > If we send S:A1 to R, then we'll have to send the whole thing, > > because R doesn't have any subvolumes yet. > > > > If we now want to send S:A2 to R, then we can use -p S:A1, and it > > will send just the differences between those two. This means that the > > send stream can potentially ignore a load of the metadata as well as > > the data. It's effectively saying, "you can clone R:A1, then do these > > things to it to get R:A2". > > > > If we now want to send S:B to R, then we can use -c S:A1 -c S:A2. > > OK this makes sense now, thanks. > > Does the use of -c always require at least two -c instances? Is there an example where -c is used once? From the man page I'm not groking that there must be at least two -c's. No, my understanding is that you could have any number (0 or more). It just allows the sending side to tell the receiving side that there's some shared data in use that it's already got the data for, and it just needs to hook up the extents. The reason I used two -cs above was because there's data that S:B shares with those two subvolumes (because that's the example scenario I picked). If S:B only shared with one subvolume, you would use only one -c. > > I'm trying to think of a case where -c is useful that doesn't > > involve someone having done cp --reflink=always between subvolumes, > > but I can't. > > OK. > > > > So, I think the summary is: > > > > * Use -p to deal with parent-child reflinks through snapshots > > * Use -c to specify other subvolumes (present on both sides) that > > might contain reflinked data > > I think the key is that -c implies a minimum of five subvolumes: two subvolumes on the source, which have (identical) counterparts on the destination (that's four subvolumes), and then one additional somehow related subvolume B on the source that I want on the destination. No, -c implies three subvolumes that exist: the one provided to the -c, which must exist on both sides as a data source, and the one being sent, which exists on the sending side, and will be recreated on the receiving side, with any shared extents replicated. > Whereas -p implies three subvolumes (one on the source which is the parent, its counterpart on the destination, and a child on the source which I want on the destination). I necessarily must understand the relationship among them in order to get the desired incremental result on the destination. I don't think you have to know that the subvol being sent is the "child" of the subvol provided with -p. I suspect that the operation would work just as well round the other way (i.e., if you've already sent the latest snapshot, you could do a cheaper copy of older snapshots by sending them with -p ). Remember, there's not really any deep FS-level concept of parent/child with snapshots. Hugo. -- === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk === PGP key: 65E74AC0 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- Sometimes, when I'm alone, I Google myself. ---