First of all, you probably meant to subdivide into rectangles, not squares. The problem is generally not solvable with squares.
Now, if you want to split your region into rectangles given an arbitrary number of rectangular holes, then I have a strong feeling it's an NP-hard problem. Which means you probably don't want to solve the problem in the best possible manner, as long as you have a solution which is "good enough".
For example, for a single-hole shape the solution that you drawn in the picture looks to be optimal. You can similarly hand-draw the solutions to the cases when the hole is at the edge or in the corner.
Now, the simplest way to solve the multi-hole problem is the following:
- Select one hole at random, and "solve" the tiling problem assuming that there are no other gaps.
- Pick another hole. It belongs to one or more of the rectangles you constructed in step 1. So solve the tiling problem recursively for each of those rectangles.
- Repeat steps 1 and 2 until all holes are accounted for.
- If you want, as a final step you may want to see if any of the adjacent rectangles can be merged into a bigger rectangle.
See the illustration: